The bootstrap Table server processes pages. net and bootstrap.net in the background.

Source: Internet
Author: User

The bootstrap Table server processes pages. net and bootstrap.net in the background.

To consider that a function can be used (called) repeatedly, You Need To encapsulate variable parameters.

Function HQCreatTables (ob) {var option = {method: 'get', dataType: "json", striped: true, // if it is set to true, the row will change color. undefinedText: "null", // the pagination: true character displayed when the data is undefined, // paginationLoop: true, // set to true to enable the function of infinite loop of paging entries. ShowToggle: false, // whether to display the switch attempt (table/card) button showColumns: false, // whether to display the content column drop-down box pageNumber: 1, // If pagination is set, homepage page number // showPaginationSwitch: true, // whether to display the number of data entries select box pageSize: 10, // If pagination is set, the number of page data entries pageList: [10, 20, 40], // If pagination is set, set the number of page data entries that can be selected. If it is set to All, All records are displayed. PaginationPreText :'? ', // Specifies the icon or text of the previous page button in the paginationNextText :'? ', // Specifies the icon or text of the next page button in the paging bar. Here is> // singleSelect: false, // setting True will disable multiple search: false, // display the search box data_local: "zh-US", // sidePagination: "server", // queryParams: function (params) on the server processing page {// custom parameters, here the parameters are passed to the background, and I use return {// here the params is the cp: params provided by table. offset, // start from the database's nth record ps: params. limit // how many lines are found};} if (ob. url) {option. url = ob. url;} if (ob. columns) {option. columns = ob. columns;} $ (ob. id ). bootstrapTable ('deststroy'); $ (ob. id ). bootstrapTable (option); if (ob. data) {$ (ob. id ). bootstrapTable ('load', ob. data) ;}$ (ob. id ). on ('Load-success. bs. table', function (data) {// listener function var $ table = $ (ob. id); var allTableData = JSON. stringify ($ table. bootstrapTable ('getdata'); // obtain all the content rows of the table. var obj = JSON. parse (allTableData); console. log (obj) Xstate. tableArr = obj ;});}

The function that is successfully written to the table is written only as needed. After the data in the table is placed in a global variable, you do not need to use ajax to query the detailed information.
This 'Load-success. bs. table 'api I still have a problem. When this table is loaded-success multiple times, this function will be run for the same number of times without affecting the page display function. However, I still don't know why the previous table was destroyed by $ (ob. id). bootstrapTable ('deststroy.
When a function is called, write its own parameters. colums is the header of the first line.

var tab = { id: '#Table', url: '/HealthRecords/Selects', columns: columns }HQCreatTables(tab);

The page value must also be included in the json file transmitted in the. net background. rows is your displayed data, total: the number of all displayed data records.

[HttpGet]        //GET: HealthRecords        public JsonResult Selects(HealthRecordView m, int cp = -4, int ps = -5, string start = null, string end = null)        {            string sa = Session["hid"].ToString();            m.hid = sa;            string sqls = " SELECT * from A where hid='" + m.hid + "'  ";            string sqlss = " SELECT count(*) from A where hid='" + m.hid + "' ";            if (!string.IsNullOrWhiteSpace(m.Name))            {                sqls += " and Name like '%" + m.Name + "%'";                sqlss += " and Name like '%" + m.Name + "%'";            }            if (!string.IsNullOrWhiteSpace(start) && !string.IsNullOrWhiteSpace(end))            {                sqls += " and r_time > '" + start + "' and r_time <'" + end + "'";                sqlss += " and r_time > '" + start + "' and r_time <'" + end + "'";            }            sqls += " order by r_time desc ";            if (cp != -4&& ps != -5)            {                sqls += "  limit  "+ cp + "," + ps + " ";            }                        var arr = db.Database.SqlQuery<HealthRecordView>(sqls).ToArray();            int RoleNames = db.Database.SqlQuery<int>(sqlss).FirstOrDefault();            return Json(new { page = cp, rows = arr, total = RoleNames }, JsonRequestBehavior.AllowGet);        }

As shown in the preceding figure, do not upload data at a time. Do not restrict tables with more conditions.
What should you do when you have query conditions?

When you see all the images, you will understand that you only need to add your query conditions in the url when calling the function.

 

Related Article

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.