Radcontrols for ASP. NET Ajax notes (1)

Source: Internet
Author: User

(1) traverse all items in the grid (one row), expand only one row at a time [single expand in hierarchical grid]

Private void radgrid1_itemcommand (Object source, telerik. Web. UI. gridcommandeventargs E)
{
If (E. commandname = radgrid. expandcollapsecommandname)
{
Foreach (griditem item in E. Item. ownertableview. Items)
{
If (item. Expanded & item! = E. item)
{
Item. Expanded = false;
}
}
}
}

Http://www.telerik.com/help/aspnet-ajax/grdsingleexpandinhierarchicalgrid.html

(2) Expand or collapse all rows

Protected void radgrid1_itemcommand (Object source, telerik. webcontrols. gridcommandeventargs E)

{

If (E. commandname = radgrid. expandcollapsecommandname)

{

(E. Item. findcontrol ("btnexpand") as imagebutton). Visible =! (E. Item. findcontrol ("btnexpand") as imagebutton). visible;

(E. Item. findcontrol ("btncollapse") as imagebutton). Visible =! (E. Item. findcontrol ("btncollapse") as imagebutton). visible;

}

If (E. commandname = "expandall ")

{

// Looping through each dataitem and making the "btnexpand" image button in the item visibility to false and "btncollapse" visibility to true

Foreach (griddataitem in radgrid1.mastertableview. getitems (New griditemtype [] {griditemtype. Item, griditemtype. alternatingitem }))

{

Imagebutton btnexpand = (imagebutton) griddataitem. findcontrol ("btnexpand ");

Btnexpand. Visible = false;

Imagebutton btncollapse = (imagebutton) griddataitem. findcontrol ("btncollapse ");

Btncollapse. Visible = true;

}

// Exapanding the dataitem

Foreach (griddataitem item in radgrid1.items)

{

Item. Expanded = true;

}

// Hiding the collapseall image in the header to true and expandall image in the header to false

Gridheaderitem = E. item as gridheaderitem;

Imagebutton imgcollapseall = (imagebutton) gridheaderitem. findcontrol ("collapseall ");

Imgcollapseall. Visible = true;

Imagebutton imgexpandall = (imagebutton) gridheaderitem. findcontrol ("expandall ");

Imgexpandall. Visible = false;

}

If (E. commandname = "collapseall ")

{

// Looping through each dataitem and making the "btnexpand" image button in the item visibility to true and "btncollapse" visibility to false

Foreach (griddataitem in radgrid1.mastertableview. getitems (New griditemtype [] {griditemtype. Item, griditemtype. alternatingitem }))

{

Imagebutton btnexpand = (imagebutton) griddataitem. findcontrol ("btnexpand ");

Btnexpand. Visible = true;

Imagebutton btncollapse = (imagebutton) griddataitem. findcontrol ("btncollapse ");

Btncollapse. Visible = false;

}

// Collapsing the dataitem

Foreach (griddataitem item in radgrid1.items)

{

Item. Expanded = false;

}

// Hiding the collapseall image in the header to false and expandall image in the header to true

Gridheaderitem = E. item as gridheaderitem;

Imagebutton imgcollapseall = (imagebutton) gridheaderitem. findcontrol ("collapseall ");

Imgcollapseall. Visible = false;

Imagebutton imgexpandall = (imagebutton) gridheaderitem. findcontrol ("expandall ");

Imgexpandall. Visible = true;

}

}

Http://www.telerik.com/community/code-library/aspnet-ajax/grid/custom-expand-collapse-column-with-expandall-collapseall-image-button-in-the-header.aspx

(3) cause the grid to rebind data [commands that invoke rebind () implicitly]

Here is the complete list of commands that triggerRebind():

Command Name

Field

Expandcollapse
Radgrid. expandcollapsecommandname

Update
Radgrid. updatecommandname

Cancel
Radgrid. cancelcommandname

Delete
Radgrid. deletecommandname

Edit
Radgrid. editcommandname

Initinsert
Radgrid. initinsertcommandname

Performinsert
Radgrid. incluminsertcommandname

Rebindgrid
Radgrid. rebindgridcommandname

Page
Radgrid. pagecommandname

Sort
Radgrid. sortcommandname

Filter
Radgrid. filtercommandname

Note that the following commandsDo notPerform internal rebind:

Select
Radgrid. selectcommandname

Deselect
Radgrid. deselectcommandname

Http://www.telerik.com/help/aspnet-ajax/grdcommandsthatinvokerebindimplicitly.html

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.