I have a question regarding free jqgrid. My jqgrid is loading fine with all data. I have given one dropdown and search button explicitly. when I am trying to search by selecting the dropdown and clicking on search button, New data is not loading into existing grid.
Here is my fiddle: https://jsfiddle.net/x3fger4z/.
On page load, I am using this url: '/MajorsView/GetAllData', but after clicking on button I wanted to load from another url.
Below is my search button and actually I am getting data in success, but it is not reflecting on grid:
<input type="button" onclick="return myfunction();" id="btnFlagStatus" value="Search" class="btn btn-primary" />
function myfunction() {
var gendarVal = $("#gendarFlagsEnum option:selected").text();
var URL= "/MajorsView/GetFemaleData?searchKey=" + gendarVal;
$.ajax({
type: "GET",
url: URL,
contentType: "application/json; charset=utf-8",
data: JSON.stringify(gendarVal),
datatype:"json",
success: function (data) {
//$("#grid").setGridParam({ url: URL })
$("#grid").trigger('reloadGrid');
},
error: function () {
alert("error");
}
})
}
I have tried to taken references from these but no avail
If you use
datatype: "json"with someurl, then you can just changeurlto another value and to triggerreloadGrid. One don't need to make a manual Ajax request. If you useloadonce: trueoption additionally, thendatatypeof the grid will be changed to"local"to process sorting, paging and filtering locally. Every sorting, paging and filtering is nothing more as reloading the grid which hasdatatype: "local"with another parameters (likepage,sortname,postData.filters). Thus to reload the data of the grid from the server one have to restoredatatypeto the initial value ("json"in your case). Thus you can useAlternatively ole can reset
datatypedirectly (withp.datatype = "json";), but the usage offromServer: truecould be helpful in other scenarios and it makes the code more readable in my opinion. See UPDATED part of the old answer for additional information.