Flexigrid add row selection event

Source: Internet
Author: User

Assume that I have an HTML table element, and there is a flexigrid corresponding to it. At the same time, the flexigird supports single choice and multiple choice is disabled. Now you need to add an event function so that it will be called when any row is clicked.

The ID of the element added to my table is subusers, and now the event function is defined. The Code is as follows:

Selectaccount: function () {// do something. Alert ('Hi :)');},

Register the above function to the click event:

$ ("# Subusers tbody TR"). Click (accounts. selectaccount );

Here we use jquery's method of searching for elements. We know that flexigird actually wraps the table, each table contains a tbody, and once it is Tr and TD,

This idea is to register accounts. selectaccount to all tr.

In this way, clicking any tr triggers the selectaccount function.

What? I don't know how to obtain the first column of the row in the event function. Jquery.

Sample Code:

Selectaccount: function () {// do nothing ());},

If you want to know whether there are any selected items, you can use the following code:

STR = $ (this). ATTR ("class"); If (Str. indexof ("trselected") =-1) {accounts. subuserid = NULL; return ;}

If-1 is returned, it is not selected.

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.