复制代码 代码如下: 然后是CenterPage.html框架中的代码,也就是tabs框架中的代码: 复制代码 代码如下: <br>//Because when the layout frame points to href, only the middle part of the html page body is taken, so the page looks like this Just write <br> // Some datagrids contain many attributes, so try to use js to initialize the datagrid framework <br>$(function () {<br>$("#dg").datagrid({<br> url: "GetJson.ashx", //Points to a general handler or a controller. The return data is required to be in Json format. You can also directly assign Json format data. I will take the Json data that comes with the demo as an example and will not write it. The background code, but I will talk about the precautions returned by the background <br>iconCls: "icon-add",<br>fitColumns: false, //Set to true to automatically adapt the columns to the table width to prevent horizontal scrolling. false will automatically match the size <br>//toolbar Set the toolbar at the top of the table and set it in the form of an array <br>idField: 'id', //Identification column, usually set to id, may be case sensitive, please pay attention <br>loadMsg: "Working hard to load data for you", //The statement displayed to the user when loading data<br>pagination: true, //Display the bottom paging toolbar<br>rownumbers: true, //Display Number of rows 1, 2, 3, 4...<br>pageSize: 10, //Read the number of paging entries, that is, the value passed when reading data to the background<br>pageList: [10, 20, 30] , //You can adjust the data displayed on each page, that is, adjust the pageSize data each time it requests data from the background<br>//Since the datagrid has too many attributes, I will not introduce each one. If necessary, you can read Its API<br>sortName: "name", //The sort field based on when initializing the table must be the same as the field name in the database<br>sortOrder: "asc", //Forward order<br>columns: [[<br>{ field: 'code', title: 'Code', width: 100 },<br>{ field: 'name', title: 'Name', width: 100, sortable: true },//sortable:true When you click on the column, you can change the ascending and descending order <br>{ field: 'addr', title: 'addr', width: 100 }<br>]],//The reason why there are two square brackets here is because it can be done In the form of a crystal report, see demo<br>toolbar: [{//Add a button at the head of the dategrid form<br>text: "Add",<br>iconCls: "icon-add",<br>handler : function () {<br>}<br>}, '-', {//'-' is to add a vertical line to separate the two buttons, which looks comfortable<br>text: "Delete",<br>iconCls: "icon-remove",<br>handler: function () {<br>}<br>}, '-', {<br>text: "Modify",<br>iconCls: "icon- edit",<br>handler: function () {<br>}<br>}, '-']<br>});<br>}); <p>//Click the search button to trigger an event<br>function searchFunc() {<br>alert("123");<br>$("#dg").datagrid("load", sy.serializeObject($ ("#searchForm").form()));//Pass the sequence of elements in the searchForm form to the background as an object<br>}</p> <p>//Click the clear button to trigger the event<br>function clearSearch() {<br>$("#dg").datagrid("load", {});//Reload the data, no data is filled in, to The value passed in the background is empty <br>$("#searchForm").find("input").val("");//Find all input tags under the form and clear them <br>}<br>< ;/script><br><div class="easyui-tabs" fit="true" border="false"><br><div title="Data display table" border="false" fit=" true"><br><div class="easyui-layout" fit="true" border="false"><br><!--Because the query requires input conditions, but it is not good in the form of toolbar , so we write the query-related information in the header north of the Layout frame --><br><!-- Here we try to make the displayed style similar to the toolbar style, so we first look for the toolbar style, And copy it--><br><div data-options="region:'north',title:'Advanced Query'" style="height: 100px; background: #F4F4F4;"><br>< ;form id="searchForm"><br><table><br><tr><br><th>User name: </th><br><td><br>< input name="name" /></td><br></tr><br><tr><br><th>Creation start time</th><br><td> ;<BR><input class="easyui-datetimebox" editable="false" name="subStartTime" /></td><br><!--Because the data on the datebox frame must be in time format Yes, so we use editable="false" to prohibit users from manually input to avoid errors --><br><th>Creation end time</th><br><td><br><input class="easyui-datetimebox" editable="false" name="nsubEndTimeame" /></td><br><td><a class="easyui-linkbutton" href="javascript:void(0 );" onclick="searchFunc();">Find</a></td><br><td><a class="easyui-linkbutton" href="javascript:void(0) ;" onclick="clearSearch();">Clear</a></td><br></tr><br></table><br></form><br> </div><br><div data-options="region:'center',split:false"><br><table id="dg"><br></table><br></div><br></div><br></div><br></div><br></p> </div> <p>Jquery extension code: </p> <p></p> <div class="codetitle"> <span><a style="CURSOR: pointer" data="23872" class="copybut" id="copybut23872" onclick="doCopy('code23872')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code23872"> <br>var sy = $.extend({}, sy) ;/*Define a global variable*/ <p>sy.serializeObject = function (form) { /*Serialize elements in the form into objects, a method that extends Jquery*/<br>var o = {};<br>$.each(form. serializeArray(), function (index) {<br>if (o[this['name']]) {<br>o[this['name']] = o[this['name']] "," this['value'];<br>} else {<br>o[this['name']] = this['value'];<br>}<br>});<br>return o;<br>};<br></p> </div> <p>Image: </p> <p><img alt="" src="http://files.jb51.net/file_images/article/201304/20130408002.jpg"></p> <p> </p>