In extjs, obtain the selected row number (multiple or single choice in grid) and grid (unselect the row)

Source: Internet
Author: User

Multiple choice, How to obtain the row number of each line:

Function getlinenum (){
VaR Sm = titlegird. getselectionmodel (); // obtain the selectionmodel of the grid.
If (Sm. getselected ()){
VaR RECs = Sm. getselections (); // put all selected items in the array
VaR linenum; // The row number.
For (VAR I = 0; I <recs. length; I ++ ){
Linenum = titlestore. indexofid (RECs [I]. Get ("titleid"); // the ID of the current row gets the current row number
Alert (linenum );
}
} Else {
Ext. msg. getdialog (). setwidth (500 );
Ext. MessageBox. Alert ("prompt", "unselected record ...");
}
}

Single choiceIt is very easy to select a single row (for example, double-click or click an event ):

VaR linenum = titlegird. getselectionmodel (). lastactive;

Note:

The row number is actually the index of each row, starting from 0!

What is the use of a row number? For example, if a row number is obtained, it can be reversed. For example, if the row number is selected for the third row, but it does not meet the value transfer requirements, you can deselect it:

VaR linenum = titlegird. getselectionmodel (). lastactive;
Titlegird. getselectionmodel (). deselectrow (linenum );

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.