Wednesday 12 June 2019

Navigation One Record at a time in Siebel IP17/18

Hello All,


In this post i will share one of the enhancement or probably i should call it fix for enabling navigation to one record at a time that has been removed in siebel IP17 onwards.

In Open UI we have now navigation controls in bottom of applet In IP 13 to IP 16, we have below controls
  1. Next Record
  2. Previous Record
  3. Next Record Set
  4. Previous Record Set



In IP17 onwards there is change in navigation controls, now there is no option of Next and Previous record in list applet, we now have

  1. Next Record Set
  2. Previous Record Set
  3. Last Record Set
  4. First Record Set



Now with the below code we can mimic the buttons to act like IP 13 to IP 16
Major Points:

1. Remove/Supress the actual functionality of Buttons,


$('[id^="next_pager_s_"]').attr('id', '');
$('[id^="last_pager_s_"]').attr('id', '');
$('[id^="first_pager_s"]').attr('id', '');

$('[id^="prev_pager_s_"]').attr('id', '');

2. Bind Click event with the Icons to perform the naviation

$('[title="Next record"]').on("click", function (e) {

if (pm.ExecuteMethod("CanInvokeMethod", "GotoNext")) {
pm.ExecuteMethod("InvokeMethod", "GotoNext");
}
e.stopImmediatePropagation();


});

if (typeof (SiebelAppFacade.DefaultNavigationPR) === "undefined") {
SiebelJS.Namespace("SiebelAppFacade.DefaultNavigationPR");
define("siebel/custom/DefaultNavigationPR", ["siebel/jqgridrenderer"], function () {

SiebelAppFacade.DefaultNavigationPR = (function () {

function DefaultNavigationPR(pm) {
SiebelAppFacade.DefaultNavigationPR.superclass.constructor.apply(this, arguments);
}

SiebelJS.Extend(DefaultNavigationPR, SiebelAppFacade.JQGridRenderer);


DefaultNavigationPR.prototype.BindEvents = function () {
$('[id^="next_pager_s_"]').removeClass('ui-state-disabled');
$('[id^="last_pager_s_"]').removeClass('ui-state-disabled');
$('[id^="first_pager_s"]').removeClass('ui-state-disabled');
$('[id^="prev_pager_s_"]').removeClass('ui-state-disabled');
$('[id^="next_pager_s_"]').attr('id', '');
$('[id^="last_pager_s_"]').attr('id', '');
$('[id^="first_pager_s"]').attr('id', '');
$('[id^="prev_pager_s_"]').attr('id', '');
var pm = this.GetPM();
var placeHolder = "s_" + pm.Get("GetFullId") + "_div";
var that = this;
var appletFullId = this.GetPM().Get("GetFullId");
//var pm = this.GetPM();
var appletPlaceHolder = $("#s_" + appletFullId + "_div"); // example: "s_S_A5" 



$('[title="Next record"]').on("click", function (e) {

if (pm.ExecuteMethod("CanInvokeMethod", "GotoNext")) {
pm.ExecuteMethod("InvokeMethod", "GotoNext");
}
e.stopImmediatePropagation();


});
$('[title="Previous record"]').on("click", function (e) {

if (pm.ExecuteMethod("CanInvokeMethod", "GotoPrevious")) {
pm.ExecuteMethod("InvokeMethod", "GotoPrevious");
}
e.stopImmediatePropagation();


});


$('[title="Previous record set"]').on("click", function (e) {

if (pm.ExecuteMethod("CanInvokeMethod", "GotoPreviousSet")) {
pm.ExecuteMethod("InvokeMethod", "GotoPreviousSet");
}
e.stopImmediatePropagation();

});

$('[title="Next record set"]').on("click", function (e) {

if (pm.ExecuteMethod("CanInvokeMethod", "GotoNextSet")) {
pm.ExecuteMethod("InvokeMethod", "GotoNextSet");
}
e.stopImmediatePropagation();

});



SiebelAppFacade.DefaultNavigationPR.superclass.BindEvents.apply(this, arguments);
}

return DefaultNavigationPR;
}());
return "SiebelAppFacade.DefaultNavigationPR";
})
}

there was a miss in the PR file as reported by one reader,  this has been catered in related post 

6 comments:

  1. Tank you for the post, very helpful. I have implemented this but buttons stay enabled all the time. Is there a easy way to disable appropriately (example on the last record next record button should be disabled)

    ReplyDelete
    Replies
    1. Hello, i tried to achieve that (to disable the icons) but could not find any way to do so, will surely give it another try. You can reach out to me rat rahulymca007@gmail.com in case any further issue.

      Delete
    2. Thank you, please let me know how it goes. I tried many things but I was not able to make it to work.

      Delete
    3. yes , i have done this one :-),
      The logic is , we need to disable or enable button based on CanInvoke result of Methods, below code does the trick ,

      function disableIcons ()
      {
      if ( pm.ExecuteMethod("CanInvokeMethod", "GotoNext") == false) {
      $("#" + appletFullId).find($('.ui-icon-seek-next')).addClass('ui-state-disabled');
      }
      else {
      $("#" + appletFullId).find($('.ui-icon-seek-next')).removeClass('ui-state-disabled');
      }
      if (pm.ExecuteMethod("CanInvokeMethod", "GotoPrevious") == false) {
      $("#" + appletFullId).find($('.ui-icon-seek-prev')).addClass('ui-state-disabled');
      }
      else {
      var a = pm.ExecuteMethod("CanInvokeMethod", "GotoPrevious");
      $("#" + appletFullId).find($('.ui-icon-seek-prev')).removeClass('ui-state-disabled');
      }
      if (pm.ExecuteMethod("CanInvokeMethod", "GotoPreviousSet")== false) {
      $("#" + appletFullId).find($('.ui-icon-seek-first')).addClass('ui-state-disabled');
      }
      else {
      $("#" + appletFullId).find($('.ui-icon-seek-first')).removeClass('ui-state-disabled');
      }
      if (pm.ExecuteMethod("CanInvokeMethod", "GotoNextSet")== false) {
      $("#" + appletFullId).find($('.ui-icon-seek-end')).addClass('ui-state-disabled');
      }
      else{
      $("#" + appletFullId).find($('.ui-icon-seek-end')).removeClass('ui-state-disabled');
      }
      }

      Mail me your Id , i will give the excat PR file ,
      to Summarize , you need to call this function , at start of BindEvents , and every time you navigate to other records , Like below code
      $("#" + appletFullId).find($('[title="Next record"]')).on("click", function (e) {


      if (pm.ExecuteMethod("CanInvokeMethod", "GotoNext")) {
      pm.ExecuteMethod("InvokeMethod", "GotoNext");
      }
      disableIcons();
      e.stopImmediatePropagation();


      });

      Delete
    4. Thank you Rahul. My email ID is yoge0315@gmail.com
      I would really appreciate if you send me the PR file.

      Delete
  2. Thanks for pointing this out, My Neurons had a good Exercise doing this one ,

    ReplyDelete

Siebel GoTo View - Handling Realtime cases

 Hello All,  We all must have used GoTo view functionality of siebel to navigate to a particular view from current view. What if the require...