Because of the project needs, the data obtained from the background is unified in order to resemble the {state:xxx,data:xxx,message:xxx} type
But the Easyui DataGrid only recognized {total:xxx,rows:xxx} ... Therefore, the entire front desk has an error, the error will be resolved, the process of solving a total of 3 in the way
1,datagrid does not directly specify the data source, but separate Ajax to get the data, and then bind it in LoadData, but this is too cumbersome, unreasonable, obviously not applicable
2, rewrite Ajax to get the data when processing, the Internet to find a section of the great God code to use, but this writing flexibility is not good, only to apply the partial verification function
(function ($) { var_ajax =$.ajax; $.ajax=function(opt) {varfn ={error:function(XMLHttpRequest, Textstatus, Errorthrown) {}, Success:function(data, Textstatus) {}}if(opt.error) {Fn.error=Opt.error; } if(opt.success) {fn.success=opt.success; } var_opt =$.extend (OPT, {error:function(XMLHttpRequest, Textstatus, Errorthrown) {fn.error (XMLHttpRequest, Textstatus, Errorthrown); }, Success:function(data, Textstatus, XHR) {fn.success (data.data, textstatus); } }); _ajax (_opt); };}) (jQuery);
3, directly with Easyui data table Properties Loadfilter ..... (a Easyui, tossing for 2 hours only to find that the data filtering function .... Pit daddy)
<script type= "Text/javascript" > $ (function () { $ (' #dgUser '). DataGrid ({ ' index.ashx ', columns: [[ ' userid ', field: ' UserID ', width:100, align: ' center ' }, ' UserName ', field: ' UserName ', width:100, align: ' center ' }] , function (data) { return data.data; } ); }); </script>
Easyui DataGrid bindings Complex Special data structures obtained from the background