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

Combo in Grid(Master) not showing text on Detail grid Expanded

3 Answers 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shafees
Top achievements
Rank 2
Shafees asked on 30 Oct 2010, 09:34 AM
<telerik:RadGrid ID="radGridActivity" runat="server" OnNeedDataSource="radGridActivity_NeedDataSource"
                            OnDeleteCommand="radGridActivity_DeleteCommand" Skin="Windows7" GridLines="None"
                            ShowStatusBar="True" OnInsertCommand="radGridActivity_InsertCommand" OnUpdateCommand="radGridActivity_UpdateCommand"
                            AutoGenerateColumns="False" OnItemCreated="radGridActivity_ItemCreated" OnItemDataBound="radGridActivity_ItemDataBound"
                            Width="1550px" OnDetailTableDataBind="radGridActivity_DetailTableDataBind">
                            <MasterTableView DataKeyNames="autoId" CommandItemDisplay="None" EditMode="EditForms"
                                Name="ContractActivity" NoMasterRecordsText="Select Contract To View And Add Activity">
                                <DetailTables>
                                    <telerik:GridTableView DataKeyNames="autoId_Items" Name="ContractActivityItems">
                                        <Columns>
                                            <telerik:GridBoundColumn DataField="cavtActivity" HeaderText="cavtActivity" UniqueName="cavtActivity">
                                                <HeaderStyle HorizontalAlign="Center" Width="150px" />
                                                <ItemStyle HorizontalAlign="Left" />
                                            </telerik:GridBoundColumn>
                                        </Columns>
                                    </telerik:GridTableView>
                                </DetailTables>
                                <Columns>
                                    <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderButtonType="None" HeaderText="Edit">
                                        <HeaderStyle HorizontalAlign="Center" Width="35px" />
                                        <ItemStyle HorizontalAlign="Center" />
                                    </telerik:GridEditCommandColumn>
                                    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmDialogType="RadWindow"
                                        ConfirmText="Are You Sure To Delete ?" ConfirmTitle="Delete" HeaderButtonType="None"
                                        HeaderText="Delete" Text="Delete" UniqueName="DeleteCommandColumn">
                                        <HeaderStyle HorizontalAlign="Center" Width="50px" />
                                        <ItemStyle HorizontalAlign="Center" />
                                    </telerik:GridButtonColumn>
                                    <telerik:GridDropDownColumn DataField="cavtActivityGroupID" HeaderText="Activity Group"
                                        UniqueName="cavtActivityGroupID" DataSourceID="sqldcActivityGroup" ListTextField="agText"
                                        ListValueField="agValue">
                                        <HeaderStyle HorizontalAlign="Center" Width="150px" />
                                        <ItemStyle HorizontalAlign="Left" />
                                    </telerik:GridDropDownColumn>
                                    <telerik:GridDropDownColumn DataField="cavtScheduleType" HeaderText="Schedule Type"
                                        UniqueName="cavtScheduleType" ListTextField="stText" ListValueField="stValue">
                                        <HeaderStyle HorizontalAlign="Center" Width="100px" />
                                        <ItemStyle HorizontalAlign="Left" />
                                    </telerik:GridDropDownColumn>
                                </Columns>
                            </MasterTableView>
                            <ClientSettings>
                                <Scrolling UseStaticHeaders="True" />
                            </ClientSettings>
                        </telerik:RadGrid>

protected void radGridActivity_ItemDataBound(object sender, GridItemEventArgs e)
   {
       /*Main Grid 1st One - Begin*/
       if ("ContractActivity".Equals(e.Item.OwnerTableView.Name))
       {
           if (e.Item is GridEditableItem && e.Item.IsInEditMode)
           {
               /*Begin Populating Combo In Edit Mode*/
               GridEditableItem edititemForCombo = (GridEditableItem)e.Item;
               GridEditManager editMan = edititemForCombo.EditManager;
               GridDropDownListColumnEditor editor = (GridDropDownListColumnEditor)(editMan.GetColumnEditor("cavtScheduleType"));
               RadComboBox radComboScheduleType = editor.ComboBoxControl;
               radComboScheduleType.DataSource = GetComboDataScheduleType();
               radComboScheduleType.DataTextField = "stText";
               radComboScheduleType.DataValueField = "stValue";
               if (!e.Item.OwnerTableView.IsItemInserted)
               {
                   DataRowView row = (DataRowView)e.Item.DataItem;
                   radComboScheduleType.SelectedValue = row["cavtScheduleType"].ToString();
               }
               radComboScheduleType.DataBind();
               /*End Populating Combo In Edit Mode*/
           }
           if (e.Item is GridDataItem && e.Item.IsDataBound && !(e.Item.IsInEditMode))
           {
               GridDataItem item = (GridDataItem)e.Item;
               DataRowView row = (DataRowView)e.Item.DataItem;
               if (row["cavtScheduleType"].ToString() == String.Empty)
                   item["cavtScheduleType"].Text = "";
               else
                   item["cavtScheduleType"].Text = row["cavtScheduleType"].ToString();
               if (row["cavtActivityGroupID"].ToString() == "0")
                   item["cavtActivityGroupID"].Text = "";
           }
       }
       /*Main Grid 1st One - End*/
   }

Problem is that When i clicked to expand DetailTableView(ContractActivityItem) The Text Displayed under the column name Schedule Type(its a combo in edit mode) became empty (its datasource is dataTable) but the Text under the column Activity Group(its also a combo) display as it is(no problem)(its datasource is sqlDatasource). How can i display the text of combo binded from code behind when in grid inside grid senario

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Nov 2010, 01:02 PM
Hello Shafees,

Try the following method to populate GridDropDownColumn .

C#:
protected void radGridActivity_ItemDataBound(object sender, GridItemEventArgs e)
    {
      if ("ContractActivity".Equals(e.Item.OwnerTableView.Name))
        {
            if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
            {
 
                GridEditFormItem edititemForCombo = (GridEditFormItem)e.Item;
                GridEditManager editMan = edititemForCombo.EditManager;
                GridDropDownListColumnEditor editor = (GridDropDownListColumnEditor)(editMan.GetColumnEditor("cavtScheduleType"));
                RadComboBox radComboScheduleType = editor.ComboBoxControl;
                editor.DataSource = GetComboDataScheduleType();
                editor.DataTextField = "FirstName";
                editor.DataValueField = "EmployeeID";
                editor.DataBind();
            }
         }
    }

Also refer the following documentation for more information on this.
Customize/Configure GridDropDownColumn

Thanks,
Princy.
0
Shafees
Top achievements
Rank 2
answered on 02 Nov 2010, 11:52 AM
Hi,

    I Tried the abow sample code , But no change to my problem. The Dynamic Combo columns Text disapear when i expand sub grid.

(item[

"cavtScheduleType"].Text = row["cavtScheduleType"].ToString(); )

 

 

0
Tsvetina
Telerik team
answered on 05 Nov 2010, 03:26 PM
Hi Shafees,

Is there any other differences between the two RadComboBoxes apart from their datasource?  Could you check what would happen if you change the datasource of the second one to be identical to the first combo's datasource? Also, what is your HierarchyLoadMode? Does the the behavior of the problemmatic control change if you switch it?

Kind regards,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Shafees
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Shafees
Top achievements
Rank 2
Tsvetina
Telerik team
Share this question
or