0

I have a jqgrid prepopulated with data. Clicking on any row will send 4 ajax requests to fetch the details (4 jsp pages get loaded). 3 pages has new jqgrids in that.

I have an external search and clear option on the first grid (jsp page). It works fine any # of times. But once I fetch the other pages with grids, the search and clear doesn't work. Ofcourse the script is getting executed but not the trigger.

I did see some solutions and have applied all but to no avail.

Grid 1:

<sjg:grid
    autowidth="true"
    id="assetgridtable"
    caption="List of Assets"
    dataType="json"
    href="%{remoteurl}"
    pager="true"
    navigator="false"
    navigatorSearch="false"
    navigatorAdd="false"
    navigatorEdit="false"
    navigatorDelete="false"
    navigatorView="false"
    navigatorExtraButtons="{
    seperator: { 
            title : 'seperator'  
        }
    }"
    gridModel="gridModel"
    rowList="10,15,20,30,50"
    rowNum="15"
    shrinkToFit="true"
    viewrecords="true"
    onSelectRowTopics="rowselect"
    loadonce="false">

Below is the subscription code for rowselect.

$.subscribe('rowselect',
  function(event, data){
    var id = event.originalEvent.id;
    $.ajax(
    {
        type : 'GET',
        url : "displayAsset.action",
        cache : false,
        data :
        {
            "id" : id
        },
        success : function(result)
        {
            $("#dataassetshow").append('<div id="assetshow"></div>');
            $("#assetshow").html(result);
            $("#assetshow").css(
            {
                "text-align" : "center",
            }).show("fast");
        }
    });

I am showing only one of the ajax calls, likewise 3 more calls are there that fetches other grids.

Now the search code

 $('#searchAsset').on('submit', function(event)
 {
    $("#assetgridtable").jqGrid('setGridParam',
    {
        type : 'GET',
        url : "listAsset.action",
        page : 1,
        datatype : 'json',
        cache : false,
        gridview : true,
        postData :
        {
            "search" : function()
            {
                return true;
            },
            "searchText" : function()
            {
                return $('#searchText').val();
            },
            "option" : function()
            {
                return $('input[name=option]:checked').val();
            },
            "from" : function()
            {
                return $('#from').val();
            },
            "to" : function()
            {
                return $('#to').val();
            },

        },
    }).trigger('reloadGrid');
    event.preventDefault();
});

As already specified, the above code works fine all the time but when other grids are fetched, it doesn't trigger the reload!!!

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
Krishnakumar R
  • 362
  • 2
  • 18

1 Answers1

1

Do not use trigger('reloadGrid') better use the reload topics.

<sjg:grid 
...
reloadTopics="reloadMyGrid"
...
/>

After that you can trigger the reload in custom javascript code like that:

$.publish("reloadMyGrid");

or by click on sj:a link like that

<sj:a ... onClickTopics="reloadMyGrid">Link</sj:a>
Johannes
  • 2,060
  • 3
  • 17
  • 27
  • And how you have try it? – Johannes Jun 04 '15 at 14:30
  • I added the above attribute and in place of ".trigger('reloadGrid');", I gave ".publish('reloadAssetGrid');" !! – Krishnakumar R Jun 04 '15 at 14:34
  • .publish('reloadAssetGrid'); works fine with a single grid as the trigger('reloadGrid'), the problem starts only when i fetch the other grids!!!! – Krishnakumar R Jun 04 '15 at 14:36
  • And each of the other grids has a trigger topic which is then published? – Johannes Jun 04 '15 at 17:01
  • Sorry for the late reply, I was travelling.. I gave the additional attribute reloadTopics to each grid and tried. Still the problem remains. I am using the publish function only for the first grid and not for subsequent grids. It just gets the data from server on page onload based on the passed id of the selected row from grid 1. – Krishnakumar R Jun 06 '15 at 05:36
  • I think I am having the same problem as in this post "http://stackoverflow.com/questions/2841705/reload-grid-not-working-for-mutiple-jqgrid?rq=1" – Krishnakumar R Jun 08 '15 at 04:40
  • After much effort, I have concluded that having multiple grids in a single page may prove detrimental. I replaced the other grids with simple tables with css applied for a jqgrid similar look and everything's perfect now!!! – Krishnakumar R Jun 08 '15 at 11:03