A small improvement on the easyui datagrid component

Source: Internet
Author: User

# A small improvement on the easyui datagrid component # when using the datagrid in an actual project, the layout is restricted. Sometimes the table cannot be too large, and the content in the table cannot be completely displayed at this time, you need to drag and adjust the column width frequently to see the complete information! [Insufficient length] ( http://images.cnitblog.com/blog/84053/201402/091301407734130.jpg ) ## Planning and thinking about the datagrid API, there are several points worth thinking about * 'fitcolumns 'attributes, ** True to auto expand/contract the size of the columns to fit the grid width and prevent horizontal scrolling **. This attribute is useful only when the datagrid width is sufficient. * 'Nowre' attribute, ** True to display data in one line **. This attribute is useful only when the height of the datagrid is sufficient. * 'Onafterrender' event, ** Fires after the view is rendered ** event can be processed after table rendering is complete, combined with the 'title' attribute in HTML, it can be used to set mouse prompts. # Write the code with a mouse prompt in the correct direction. But where should I place the prompt? Here we need to analyze the HTML after the datagrid is rendered! [Generated HTML] ( http://images.cnitblog.com/blog/84053/201402/091309482037806.jpg ) You can see that the table content is in the div element of the class 'datagrid-cell ', so you need to write code to add the title attribute at the beginning, I am directly modifying the '''javascript $ OF THE 'onafterrender' event. fn. datagrid. defaults. view. onAfterRender = function (tgt) {$ (tgt ). datagrid ("getPanel "). find ("div. datagrid-body "). find ("div. datagrid-cell "). each (function () {var $ Obj = $ (this) $ Obj. attr ("title", $ Obj. text () ;}}''' later, it was found that some datagrid with onAfterRender events will overwrite the original events, so after some code details adjustments, '''javascriptvar o RiFunc = $. fn. datagrid. defaults. view. onAfterRender; $. fn. datagrid. defaults. view. onAfterRender = function (tgt) {oriFunc (tgt); $ (tgt ). datagrid ("getPanel "). find ("div. datagrid-body "). find ("div. datagrid-cell "). each (function () {var $ Obj = $ (this) $ Obj. attr ("title", $ Obj. text () ;}}''' ## solution effect! [Add a mouse prompt] ( http://images.cnitblog.com/blog/84053/201402/091301554347141.jpg ) This is an improvement in user experience # complete example and code [DEMO] ( http://p2227.github.io/demo/datagrid/ ) [Code (Summary of jquery/easyui functions commonly used in projects)] ( http://www.cnblogs.com/p2227/p/3541143.html )

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.