如何从另一个url重新加载jqxGrid数据

时间:2022-08-25 22:09:42

I have a jqxGrid form JqWidgets library , I have bound the data to the jqxGrid like so..

我有一个jqxGrid表单JqWidgets库,我像这样将数据绑定到jqxGrid。

 var url = "getConsignments.php?type="+$('#selectIsDelevered').val();

      var consignmentsource =
          {
            datafields: [
              {
                name: 'ConsignmentId', type: 'string'  }
              ,{
                name: 'Name' , type: 'string' }

            ],
            id: 'ConsignmentId',
            datatype: "json",
            async: false,
            cache:false,
            url: url ,
            filter: function()
      {
        // update the grid and send a request to the server.
        $("#jqxgrid").jqxGrid('updatebounddata', 'filter');
      },
      sort: function()
        {
          // update the grid and send a request to the server.
          $("#jqxgrid").jqxGrid('updatebounddata', 'sort');

        },
          root: 'Rows',
          cache: false,
    beforeprocessing: function(data)
    {   
      if (data != null)
      {
        consignmentsource.totalrecords = data[0].TotalRows;          
      }
    }
          }

This for initionalizing and server call. the bellow code is for binding to the data I get from the server

这适用于本地化和服务器调用。下面的代码用于绑定从服务器获得的数据

consignmentAdapter = new $.jqx.dataAdapter(consignmentsource);

  $("#jqxgrid").jqxGrid(
      {
        source: consignmentAdapter,
        theme:'bootstrap',
        columnsresize:true,
        width: '100%',

          filterable:true,
        autoheight:true,

        rowdetails: true,
        autorowheight :true,
        showfilterrow: true,
        pageable:true,
        sortable: true,
        virtualmode: true,
        rendergridrows: function()
        {
            return consignmentAdapter.records;     
        },


        ready: function () {
          // $("#jqxgrid").jqxGrid('showrowdetails', 1);
        }
        ,
        columns: [
          {
            text: 'ID', width: '10%',datafield:  'ConsignmentId'}
          ,
          {
            text: 'Name', datafield: 'Name', width: '18%' }
        ]
      }
    );

The selectIsDelevered is a select tag has 3 options , every option loads different data, I wand to do the rebind , reload , or refresh the grid with the ('#selectIsDelevered').change() function I have tested $('#jqxGrid').jqxGrid('updatebounddata'); but it didn't work , even I have tried $('#jqxGrid').jqxGrid('refresh'); with repeating the binding steps . I took me 3 days , Any suggestion ?!!

selectis去杠杆化是一个select标记有3个选项,每个选项都装载不同的数据,我希望使用('# selectis去杠杆化').change()函数测试$('#jqxGrid').jqxGrid('updatebounddata');但是它不起作用,即使我尝试过$('#jqxGrid').jqxGrid('refresh');通过重复绑定步骤。我花了三天时间,有什么建议吗?!

1 个解决方案

#1


3  

You can change url directly as the following code:

您可以直接将url更改为以下代码:

('#selectIsDelevered').change({
   var tmpS = $("#jqxgrid").jqxGrid('source');
   tmpS._source.url = "getConsignments.php?type="+$('#selectIsDelevered').val();
   $("#jqxgrid").jqxGrid('source', tmpS);
});

#1


3  

You can change url directly as the following code:

您可以直接将url更改为以下代码:

('#selectIsDelevered').change({
   var tmpS = $("#jqxgrid").jqxGrid('source');
   tmpS._source.url = "getConsignments.php?type="+$('#selectIsDelevered').val();
   $("#jqxgrid").jqxGrid('source', tmpS);
});