Easyui DataGrid loads two requests, triggering two AJAX request issues

Source: Internet
Author: User

Request URL two times when the DataGrid is initialized

Two cases

1.

<id= "GridView"  class= "Easyui-datagrid"></ Table >
$(function(){  $("#gridview"). DataGrid ({URL:"Getdata.do", Title:List, Singleselect:false, pagination:true, toolbar:"#toolbar", Method:"Get", columns:[[{field:"CK", checkbox:true}, {field:"id", Title: "id", width:20,sortable:true}, {field:"Kindname", Title: "Name", Width:100,resizable:true, sortable:true}, {field:"CreateDate", Title: "Date Created", Width:80,resizable:true, sortable:true}    ]]  }); })

Because the table in the grid is written class= "Easyui-datagrid", in addition to the initialization of JS has a URL so that it will request two times getdata.do, will class= "Easyui-datagrid" removed.

Second case:

    

$ (function() {
$ ('. Sfc7450_main_table1 '). DataGrid ({url: ' Table.json ',//load local jsonrownumbers:true,//If the serial number is displayed pagination:true,// Whether to add tab pageposition: ' Bottom ',//Page location method: ' Get ',//Get type singleselect:true,//whether Radio fitcolumns:false,// Whether the cell is self-adapting to fill the table width columns:[sfc7450_table[0]]});

});

$ ('. Sfc7450_main_table1 '). DataGrid ({url: '/sfc/a.do ',//load local jsonrownumbers:true,//If the serial number is displayed pagination:true,// Whether to add tab pageposition: ' Bottom ',//Page location method: ' Get ',//Get type singleselect:true,//whether Radio fitcolumns:false,// Whether the cell is self-adapting to fill the table width columns:[sfc7450_table[0]]});
This time there will be a strange phenomenon: JS debugging observation Network will see the request sfc/a.do. After the request is completed and then requested a table.json ... WORKAROUND: Instead of requesting a URL at initialization time, use data to assign an empty array (why do we initialize an empty table for the page to look good at the beginning)
Blank josn 5 row var kongjson5=[{"": "", "": "," "" "," "", "", "" "", "" "" "," "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ,"":"","":"","":"","":"","":"","":""},{"":"","":"","":"","":"","":"","":"","":"","":"","":"","":""},{"":"","":" ","":"","":"","":"","":"","":"","":"","":"","":""},{"":"","":"","":"","":"","":"","":"","":"","":"","":"","":""} ]

Change to the following $ ('. Sfc7450_main_table1 '). DataGrid ({
data:kongjson5,//loading Local JSON
rownumbers:true,//serial number Shows whether pagination:true,//add tab pageposition: ' Bottom ',//Page location method: ' Get ',//Get type Singleselect: true,//whether the radio fitcolumns:false,//cell is self-adapting to fill the table width columns:[sfc7450_table[0]});

  

<table id="GridView" class="Easyui-datagrid"> </table>

Easyui DataGrid loads two requests, triggering two AJAX request issues

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.