FLEX gets the DataGrid line number and column number sample code _flex

Source: Internet
Author: User
Tags error handling floor function
first, get the line number
Copy Code code as follows:

var findex:number = Math.floor (dg.contentmousey/dg.rowheight)-1 + dg.verticalscrollposition;
Dg.contentmousey is the height of the local coordinate system of the mouse in relation to the DataGrid
Dg.rowheight is the row height of the DataGrid, the Math.floor function is to truncate the decimal point
Verticalscrollposition is the number of rows to scroll down if the DataGrid has scroll bars. So Findex is the number of rows the mouse is in.
Error handling if (findex<0 | | findex>=dg.verticalscrollposition+dg.rowcount-1)//line number is less than 0 o'clock and greater than the total number of DataGrid rows
{
Don't do anything.
} else {
.............
}

second, get the column number
Copy Code code as follows:

var _editcolumn:datagridcolumn=dgrainrealtime.columns[ Event.columnindex];
var editvalue:string=dgrainrealtime.itemeditorinstance[_editcolumn.editordatafield];//Get the edited rainfall value
var _ Editvalue:int=int (EditValue);
Var _row:int=dgrainrealtime.editeditemposition.rowindex;
Var _column:int=dgrainrealtime.editeditemposition.columnindex;
var col:datagridcolumn=dgrainrealtime.columns[_column-1];
var devicename:string=dgrainrealtime.dataprovider.getitemat (_row) [Col.datafield];//The site name of the edited rainfall value obtained

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.