Search code examples
jqueryasp.netjqxgridjqxwidgets

How to bind ajax result to jqxGrid


How can I bind the ajax result to jqxGrid? I got confused on how to do it the right way because in the jqxGrid samples their source is just a text file. Anyone could give me idea to do it the right way will be a big help

as of now here is my ajax code returning a result

$.ajax({
        type: 'post',
        url: 'ws.asmx/GetStudentsById',
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        data: JSON.stringify({
            studID: id
        }),
        success: function (data) {
var toAppend ='<table>';
$.each(data, function (key, val) {
for (var i = 0; i < val.length; i++) {
    toAppend+='<tr>';
    toAppend+='<td>'+val[i]['StudID']+'</td>';
    toAppend+='<td>'+val[i]['StudName']+'</td>';
    toAppend+='</tr>';
}
toAppend += '</tbody></table>';
            });
$('#results').append(toAppend); 
         }

});

under the success i want to change it to jqxGrid and i dont know how should i start it. thanks


Solution

  • You need to change the dataType to xml as you're using legacy asmx service which gets the content as XML by default, not json.

    http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxdataadapter/jquery-data-adapter.htm