Home > front end >  The query
The query

Time:12-02

1. Load a table
1.1. Declaration form, perform rendering, there are three kinds of rendering: 1). Methods rendering, complete the rendering with JS method of configuration, without having to write too much HTML, JS in specified in the original elements, set the parameters again can, 2). Automatic rendering, HTML configuration, u-shaped enron automatically, without having to write too much JS, to concentrate on the HTML header section, 3) into a static form, into an existing table element, no configuration data interface, the specified form elements in JS, and simply add custom attributes to header can
Var layui table name;
Table name=layui table name. Render. Render ({
Parameter
1.2.Elem: '# demo//specify the original table container, the selector or DOM rendering method required (recommended id selector)
Height: Number/the String//container height
Page: Boolean/Object//open the Page
Limit: article Number//display a page Number (default: 10)
Limits: Array//each page of the number of options, the default:,20,30,40,50,60,70,80,90 [10],
.
1.3. Set the header
Cols: [[//title bar
{
Field: the String//(should) set the field name, field name of the setting is very important, and is a unique identifier for the data of columns in a table
Title: the String//(mandatory) to set header name
Width: Number/String//set the column Width (automatically assigned by default) and support to fill in: Numbers, percentages,
MinWidth: Number//local define the minimum width of the current conventional cell (default: 60), commonly used in column widths automatically assigned
the condition of theType: the String//set the column type, optional values are: normal (regular columns, need not set), the checkbox (check box), space (null columns), Numbers (serial number column)
Fixed: the String//fixed columns, optional values are: left (on the left), right (on the right), once set, the corresponding column will be fixed to the left or the right, not with the scroll bar rolling,
Style: the String//custom cell Style, namely afferent CSS Style
Align: the String//cell arrangement, optional values are: left (the default), center (center), right (right)... }
]]
});
2. To the controller data paging query students
2.1 list query out the needed data
2.2. On the condition of handsome choice:
If (condition) {
Variable name 1=a variable name (1) the Where (=custom name & gt; The custom name. Need to query the data. The Contains (need to query data));
}
2.3. Paging query student data
ListOrderByDescending (custom name=& gt; A custom name. Data ID)//ID flashback sequence according to the data
Skip (controller data. GetStartIndex ())//to Skip the front pages of data
Take (controller data. Limit)/article/query data on this page number
ToList ();//return the List collection
2.4. Query student data to the total number of article
Int variable name 3=myModel. Custom table name. The Count ();
2.5. Prepare Layui Table required data format (generic)
LayuiTableDataThe count variable name=2,//the total number of article data=https://bbs.csdn.net/topics/variable name 3,//the data on this page
}
2.6. Return Json: returnJson (variable names 4, JsonRequestBehavior. AllowGet);
3. To view began to query the table
3.1. Input data access page
3.2. Form the overloaded
The table name. Reload ({
Where: {
Page input the data of 1:1 input data,
2: the page of the input data input data page 2,
. },
Page: {
Curr: 1//again from the first page
}
});
  • Related