Infragistics. webui. ultrawebgrid has powerful functions, especially the client time is rich, which can achieve more control. The following describes some client events.
In. CSCodeAdd
Code
Ultrawebgrid1.displaylayout. clientsideevents. cellclickhandler = " Template_cellclickhandler " ;
Ultrawebgrid1.displaylayout. clientsideevents. columnheaderclickhandler = " Template_columnheaderclickhandler " ;
Ultrawebgrid1.displaylayout. clientsideevents. aftercellupdatehandler = " Template_aftercellupdatehandler " ;
Ultrawebgrid1.displaylayout. clientsideevents. afterrowactivatehandler = " Template_afterrowactivatehandler " ;
The above four items are: Cell Click Event, column header Click Event, cell update event, and row event.
Note: You must modify cellclickactiondefault = "cellselect" in the style layout section of the control on the previous page. If yes
Select cellclickactiondefault = "rowselect" for the row"
Code
< Displaylayout Rowheightdefault = "24px" Version = "4.00" Bordercollapsedefault = "Separate" Loadondemand = "XML" Tablelayout = "Fixed"
Cellclickactiondefault = "Cellselect" Selecttyperowdefault = "Single" Rowselectorsdefault = "No" Selecttypecelldefault = "Extended" >
Then write client events
Code
// Declare several common global variables
VaR Currentgrid = Null ;
VaR Currentrowindex =- 1 ;
VaR Currentcolumnindex =- 1 ;
VaR Currentrow = Null ;
VaR Currentcell = Null ;
// Cell click
Function Template_cellclickhandler (gridname, cellid, button)
{
If (Button = 2 )
Return ;
Currentgrid = Igtbl_getgridbyid (ultrawebgrid1 );
Currentcell = Currentgrid. getactivecell ();
Currentcolumnindex = Currentcell. index;
Currentrow = Currentcell. row;
Currentrowindex = Currentrow. getindex ();
//Other js code you want to execute
}
//Row Click Event
FunctionTemplate_afterrowactivatehandler (gridid, rowid)
{
Currentrow=Igtbl_getrowbyid (rowid );
Currentrowindex=Currentrow. getindex ();
//Other js code you want to execute
}
//Click the event in the header (the parameter is not written and you can find it yourself)
FunctionTemplate_columnheaderclickhandler ()
{
}
//Post-cell update events
FunctionTemplate_aftercellupdatehandler (gridname, cellid)
{
}
Other common operations
Function Deleterow ()
{
VaR Row = Igtbl_getactiverow (ultrawebgrid1 );
Currentrow = Row;
// Sometimes you need to perform some checks. After certain conditions are met, a callback function is executed to delete the row. Therefore, the current row is saved in the global variable.
Currentrow. deleterow ();
}
Add row:
Function Insertrow ()
{
Currentgrid = Igtbl_getgridbyid (ultrawebgrid1 );
Currentgrid. Rows. addnew ();
//To obtain the newly added row, you can return (return) the newly added row, and then perform operations such as automatic assignment.
VaRRow=Igtbl_getrowbyid (currentgrid. Rows. getlastrowid ());
//Obtain the next row of the current row.
VaRRow=Currentrow. getnextrow ();
}
Obtain a row or cell by ID
Igtbl_getcellbyid (cellid );
Igtbl_getrowbyid (rowid );
If the cell is an image, you can assign a value like this.
Addcell. element. innerhtml = " <Nobr> " Cursor: hand \ " Onclick = insertrow () src = \ " .. / Images / Default / Add.bmp \ "> < / Nobr > " ;
If it is text, it should
Row. getcell (columnindex );
Cell. setvalue ();
More use skills are in progress!