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

Grid shows edit form on load

2 Answers 12 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
Veteran
David asked on 07 Aug 2014, 07:36 PM
For some reason when my grid loads it keeps edit form open for first record. Please help!
Additional question: is there a way to show number of sub records in hierarchical grids?

Thank you

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 08 Aug 2014, 05:26 AM
Hi David,

About your first issue, please make sure that you haven't made the grid to be open in edit mode initially in PreRender event or any. Check your code once more, if not able to resolve, provide your full code snippet. I'm not sure where you want to display the number of sub records, please try the following code snippet to get the number of sub records and display it along with the ExpandColumn.

C#:
protected void rgdrSample_PreRender(object sender, EventArgs e)
{
    CountofItems(rgdrSample.MasterTableView);
}
public void CountofItems(GridTableView tableView)
{
    GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
    foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
    {
        foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
        {
            TableCell cell = nestedView.ParentItem["ExpandColumn"];
            Label lblDisplay = new Label();
            lblDisplay.ID = "lblDisplay";
            lblDisplay.Text = nestedView.Items.Count.ToString();
            cell.Controls.AddAt(1, lblDisplay);
 
            if (nestedView.HasDetailTables)
            {
                CountofItems(nestedView);
            }
        }
    }
}

Thanks,
Shinu
0
David
Top achievements
Rank 1
Veteran
answered on 08 Aug 2014, 02:38 PM
Hi Shinu,

   You were right regarding first question! Somehow code i copied from Telerik demo contained code on PreRender. I removed it and all set now.
  Code you provide for second question was interesting solution, but didn't work for all cases. Regardless i solved it with some sql.

Thanks a lot
Tags
Grid
Asked by
David
Top achievements
Rank 1
Veteran
Answers by
Shinu
Top achievements
Rank 1
David
Top achievements
Rank 1
Veteran
Share this question
or