Easyui DataGrid bindings Complex Special data structures obtained from the background

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.