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

Hide column of DetailTables in Edit mode

4 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
d-cpt
Top achievements
Rank 2
d-cpt asked on 18 Sep 2008, 03:03 PM
I have a hierarchical grid similar to the demo as Customer > Orders. The DetailTables "Orders" has a gridboundcolumn (A) for viewing data  and a griddropdowncolumn (B) that only is visible in edit mode and bind to another SqlDataSource. How to hide the gridboundcolumn (A) in edit mode?
(B) works fine.
The test is similar to this demo: http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/DataEditing/ThreeLevel/DefaultCS.aspx

I tried to do this but it still does not work:

protected void radgridAccount_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item.OwnerTableView.Name == "Orders")
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item as GridEditableItem;
if (item.IsInEditMode)
{
//either these lines
this.radgridAccount.MasterTableView.DetailTables[0].Columns[1].Visible = false;this.radgridAccount.MasterTableView.DetailTables[0].Columns[2].Visible = false;
//or these lines
Item["A"].Controls[0].Visible = false;
item[
"B"].Controls[0].Visible = true;
}}}}

Thanks.
d-cpt


4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Sep 2008, 06:21 AM
Hi,

Try the following code snippet in the PreRender event of the Grid and see if it is working.

CS:
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
        { 
            if (item.Expanded) 
            { 
                 
                    GridTableView nestedView = ((GridDataItem)item).ChildItem.NestedTableViews[0]; 
                    foreach (GridItem childitem in nestedView.GetItems(GridItemType.Item)) 
                    { 
                        if (childitem.Edit) 
                        { 
                            nestedView.GetColumn("columnUniqueName").Visible = false
                           
                        } 
                    } 
                
            } 
        } 
         
    } 


Regards
Shinu.
0
d-cpt
Top achievements
Rank 2
answered on 19 Sep 2008, 02:10 PM
Hi Shinu,

Thanks for your quick reply. It still doesn't work. The gris's EditMode is EditForms. Does the form using columns as in InPlace mode?

Regards,

d-cpt
0
Shinu
Top achievements
Rank 2
answered on 22 Sep 2008, 05:43 AM
Hi d-cpt,

The above given code will not work with InPlace edit mode. Try setting the EditMode to either EditForms or Popup to achieve the desired scenario.

Thanks
Shinu.
0
d-cpt
Top achievements
Rank 2
answered on 23 Sep 2008, 01:30 PM
Hi Shinu,

I tried but it still doesn't work.

Thanks,

d-cpt
Tags
Grid
Asked by
d-cpt
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
d-cpt
Top achievements
Rank 2
Share this question
or