Beginners Learn jquery Easyui---DataGrid right-click menu

Source: Internet
Author: User

recently learning jquery Easyui, now say the Easyui of the DataGrid, generally when we implement the front-end interface, often in the DataGrid

The above or behind add some buttons, convenient for users to add, delete, edit and other functions

in each use, the user needs to select one or more data, and then go to the Point button to do the relevant operations, which is actually very troublesome

, in the process of doing the project, for the sake of the user, made a right-click menu, the user wants to delete or edit a piece of data directly in its location right-click

just you can. The following code:

HTML Code

<div id= "Menu" class= "Easyui-menu" style= "width:30px; Display:none; " >      <!--Place a hidden menu div-->      <div id= "Btn_delete" data-options= "iconcls: ' Icon-remove '" onclick= "" > Delete </div>      <!--specific menu events Please add it yourself, the method with toolbar is basically the same--      <div id= "btn_modify" data-options= " Iconcls: ' Icon-edit ' > Edit </div> </div>

Here's the code for JavaScript

DataGrid Right-click menu code: $ ("#dg"). DataGrid ({    onrowcontextmenu:function (E, RowIndex, rowdata) {//Right-triggered event        // Three parameters: E inside a lot of content, really do not understand, rowindex is the current click on the index of the line, rowdata the current row of data        e.preventdefault ();//prevent the browser from capturing right-click event        $ (this). DataGrid ("Clearselections"); Cancels all selected items        $ (this). DataGrid ("SelectRow", rowIndex);//Select the row        $ (' #menu ') according to the Index. Menu (' show ', {            //Display right-click menu            left:e.pagex,//Show Menu Top:e.pagey} at mouse            click        );        E.preventdefault ();  Prevent browser from bringing up the right-click menu Popup    });

Here is the effect after the implementation:


Now just a simple implementation of the right-click menu, and later there will be improvements. What we do out of the end is to give the user to use, for the sake of the user,

How to let the user comfortable, in the user unexpected time, to help users complete the work they want to complete, this is the biggest success of this software!

Beginners Learn jquery Easyui---DataGrid right-click menu

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.