jquery Easyui displays sortable fields when the DataGrid is initialized

Source: Internet
Author: User

In the list using the easy UI, you want to mark the fields that can be sorted, so that users can see which ones are sorted by clicking on the page.

Add an icon to the sortable field after the column name. The unordered field is also the same as the original.

Steps:

    1. You need an icon,

    2. You need to add the following code to your easy UI source

      $ ("span", TD). HTML (col.title);
      $ ("Span.datagrid-sort-icon", TD). HTML (" ");
      var cell=td.find ("Div.datagrid-cell");
      if (Opts.sortname = = Col.field) {
      Cell.addclass ("datagrid-sort-" + opts.sortorder);
      } else if (col.sortable==true) {
      Cell.addclass ("Datagrid-sort");
      }

      One of the last else if parts is manually added.

    3. Finally, add the app CSS to your project to

      . datagrid-sort. Datagrid-sort-icon {
      padding:0 13px 0 0;
      margin-left:4px;
      Background:url (' images/sorter.png ') no-repeat 0px Center;
      }
      . datagrid-sort-asc. Datagrid-sort-icon,.datagrid-sort-desc. Datagrid-sort-icon {
      margin-left:0px;
      }

      Note: The picture can be freely chosen, secondly, the style name can be freely selected ("Datagrid-sort" for my Custom), finally, my easy UI is compressed version 1.3.2, search "Datagrid-sort-icon" can find the corresponding Code section, find

      if (Opts.sortname = = Col.field) {
      Cell.addclass ("datagrid-sort-" + opts.sortorder);
      Add a branch to the IF statement

      else if (col.sortable==true) {
      Cell.addclass ("Datagrid-sort");
      }

      Last one.

jquery Easyui displays sortable fields when the DataGrid is initialized

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.