This is a migrated thread and some comments may be shown as answers.

Validation on ExpandCollapseColumn

2 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 20 Oct 2008, 08:03 PM
Is there a way to show a validation message on attempting to expand or collapse?

What I have is a grid with an editable NumericTextBox in the ItemTemplate of one of the columns. It is the only value that is editable on the given row of the grid but it is editable immediately on viewing the grid. I have a top level Save button such that when clicked it saves all of the values entered in any of the textboxes on the grid.

However, these same rows can have child records. The catch is that if there is no value greater than zero entered in the parent row's NumericTextBox, the user shouldn't be able to expand the child rows.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Oct 2008, 04:46 AM
Hi,

Try the following code snippet to achieve the required scenario:
CS:
  protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
        { 
            if (e.CommandName == RadGrid.ExpandCollapseCommandName) 
            { 
                GridDataItem item = (GridDataItem)e.Item; 
                if (item.GetDataKeyValue("CompanyName").ToString() == "Around the Horn") 
                { 
                    e.Canceled=true
                } 
            } 
        } 


Thanks,
Shinu
0
Thomas
Top achievements
Rank 1
answered on 21 Oct 2008, 03:13 PM
Thank you! I discovered this very same technique yesterday after I wrote my post.
Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Thomas
Top achievements
Rank 1
Share this question
or