Fabii
Fabii

Reputation: 3890

How do I load new data JSON data into a jqGrid?

I have a dropdownlist with the id "mylist", when an item is selected in the dropdownlist I trigger GetNewGridData in my controller class which sends back JSON data which I want to load into my grid, how do I load this new data into the grid?

$("#mylist").change(function () {
           var value = $(this).val();
           alert(value);

           $.ajax({
               url: '<%= Url.Action("GetNewGridData`", "Billing") %>',
               success: function (data) {
                   alert(data);
                   jQuery("#BillingGrid").setGridData('postData', data).trigger('reloadGrid');                                
               }
           });
       });

Upvotes: 0

Views: 1780

Answers (1)

Fabii
Fabii

Reputation: 3890

The following seem to have done the trick : $('#BillingGrid').setGridParam({ url: '<%= Url.Action("GetGridData1", "Billing") %>' });


$("#mylist").change(function () {
               var value = $(this).val();
               alert(value);

               $.ajax({
                   url: '<%= Url.Action("GetGridData1", "Billing") %>',
                   success: function (data) {
                       alert(data);
                       $('#BillingGrid').setGridParam({ url: '<%= Url.Action("GetGridData1", "Billing") %>' });
                       $('#BillingGrid').trigger('reloadGrid');

                   }
               });
           });

Upvotes: 2

Related Questions