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

Expand NestedView On Row Click

2 Answers 221 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 18 Jan 2009, 05:54 PM
I am new to these controls and still evaluating them.  I cant seem to figure something out that I really want to happen and was hoping someone here could point me in the right direction.

I have a grid that lists just a few columns from a table. When the user selects a row I want to display a formView control with all of the remaining columns and allow them to edit, delete, etc...

I have all of that working using a <NestedViewTemplate>

However, it seems that clicking the row to select it does nothing, I have to resort to clicking the expand/collapse button on the left.
                 
Is there a way to eliminate the expand/collapse button all together and make that happen on row click (select)?

If not, is there a way to change my expand collapse button?  I have changed the Button Type in the MasterTableView.ExpandCollapseColumn property a million times and nothing takes affect...???

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 19 Jan 2009, 04:52 AM
Hello Shawn,

Try out the following code to have the NeatedViewTemplate for a parent row expanded on clicking on the row.
cs:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "RowClick") 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            item.Expanded = !item.Expanded
        } 
    } 

And to hide the ExpandCollapse column, you can try out the following code in the column created event of the grid.
cs:
protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) 
    { 
        if (e.Column.UniqueName == "ExpandColumn") 
            { 
              e.Column.Visible = false
            } 
    } 

Thanks
Princy.
0
Shawn
Top achievements
Rank 1
answered on 19 Jan 2009, 08:31 PM
Awesome - that worked!

Although I have a differrent problem now that I am unsure of how to handle....

Basically I created my FormView outside of the <NestedViewTemplate> so that I could see it in design and get it just how I wanted it.  After getting to work properly I put it back so that it is displayed under the row, but now I am getting the following error when trying to compile and run the code:

Protected Sub FormView1_ItemUpdating(ByVal sender As ObjectByVal e As System.Web.UI.WebControls.FormViewUpdateEventArgs) Handles FormView1.ItemUpdating 
Line 72:         Dim cat_id As Integer = sender.findcontrol("list_categoryID").selectedvalue 
Line 73:         Dim web_id As Integer = sender.findcontrol("list_companywebsites").selectedvalue 
SqlDataSource1.UpdateCommand = 'my update command here 
End Sub 

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.


Am I missing something...?



Tags
Grid
Asked by
Shawn
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Shawn
Top achievements
Rank 1
Share this question
or