Use of infragistics. webui. ultrawebgrid

Source: Internet
Author: User

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!

 

 

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.