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

RadGrid with an enabled RadComboBox on each row?

6 Answers 255 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 20 Mar 2012, 10:07 PM
Hi - I'm struggling with something that I can't seem to figure out.  I want to be able to display a RadComboBox that can be used on each row.  I need this because setting up the data I'm using requires a selection be made for each row.  My grid markup is as follows:

 

<telerik:RadGrid ID="grdRules" runat="server" GridLines="None" AutoGenerateColumns="False" OnItemCreated="grdRules_ItemCreated"
HorizontalAlign="NotSet" OnNeedDataSource="grdRules_NeedDataSource" Width="99%" OnPreRender="grdRules_PreRender" PageSize="100">
    <MasterTableView DataKeyNames="ID" GridLines="None" Width="100%" EditMode="InPlace">
        <Columns>
            <telerik:GridCheckBoxColumn UniqueName="IncludeRuleColumn"/>
            <telerik:GridTemplateColumn UniqueName="RuleName" HeaderText="Name" DataField="Name" SortExpression="Name">
                <ItemTemplate>
                    <asp:Label ID="lblName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Message" UniqueName="ValidationMessage" DataField="MessageText" SortExpression="Message.MessageText">
                <ItemTemplate>
                    <telerik:RadComboBox runat="server" ID="cbMessage" OnDataBinding="cbMessages_DataBinding" DataTextField="MessageText" DataValueField="ID"></telerik:RadComboBox>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Outcome" UniqueName="OutcomeType" SortExpression="OutcomeType">
                <ItemTemplate>
                    <telerik:RadComboBox runat="server" ID="cbOutcomeTypes" OnDataBinding="cbOutcomeTypes_DataBinding"></telerik:RadComboBox>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

 

When the grid displays, they all look like the RadComboBox, but they're all disabled and cannot be 'dropped down' to select an item.  I've tried forcing all of the rows into edit mode with EditItemTemplate entries as well, and that doesn't work either.  Here is the server side code I've tried that with:

protected void grdRules_PreRender(object sender, EventArgs e)
{
    foreach (GridItem item in grdRules.MasterTableView.Items)
    {
        if (item is GridEditableItem)
        {
            GridEditableItem editableItem = item as GridDataItem;
            editableItem.Edit = true;
        }
    }
    for (int i = 0; i < grdRules.PageSize; i++)
    {
        grdRules.EditIndexes.Add(i);
    }
    grdRules.Rebind();
}
protected void grdRules_ItemCreated(object sender, GridItemEventArgs e)
{
    if(!Page.IsPostBack && e.Item is GridEditableItem)
    {
        e.Item.Edit = true;
    }
}

Is what I'm explaining possible with the RadGrid?  What am I missing here?  I feel like I've tried everything today to get this to work, and to no avail.  Ideas please?  Thanks!

6 Answers, 1 is accepted

Sort by
0
Jeff
Top achievements
Rank 1
answered on 22 Mar 2012, 03:09 PM
No ideas here guys?
0
Pavlina
Telerik team
answered on 23 Mar 2012, 07:29 AM
Hello Jeff,

You can examine to the online example below which demonstrates how you can use numerous different instances of RadComboBox inside RadGrid
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/comboingrid/defaultcs.aspx?product=grid

Greetings,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jeff
Top achievements
Rank 1
answered on 23 Mar 2012, 02:45 PM
Hi Pavlina,

I looked at your example, and maybe I'm not being clear - I want the entire grid in edit mode, and to have combo boxes enabled on all rows at the same time, similar to the attached screenshot.  I have multiple comboboxes set up on the grid in a single row edit or add, but I want them all enabled on every row when I force all rows to edit mode.  Does that make sense?

In the attached screenshot I have all rows in edit mode, and I have the combo boxes in the cells - but they aren't 'enabled', meaning I can't get them to drop down.  I don't know what I'm missing here?
0
Pavlina
Telerik team
answered on 28 Mar 2012, 01:05 PM
Hello Jeff,

The online resources below show how can use combobox in grid and how to put all items in edit mode:
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/comboingrid/defaultcs.aspx?product=grid

http://www.telerik.com/help/aspnet-ajax/grid-put-all-items-in-edit-mode-no-additional-rebind.html

Give a try with logic in them and see if they help to achieve your goal.

Regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jeff
Top achievements
Rank 1
answered on 28 Mar 2012, 02:59 PM
As you can see in the code I provided above, I've tried the suggestions at the links you provided.  I've looked at countless demos of the grid on your site, and haven't seen one doing what I need it to do.  I will assume at this point the grid is not capable of doing what I need it to do in this instance.  Thanks.
0
Pavlina
Telerik team
answered on 02 Apr 2012, 02:33 PM
Hi Jeff,

I followed your scenario and prepared a sample runnable  project which demonstrates how you can achieve the desired functionality. Give it a try and let me know if it works for you or if I am leaving something out.

Greetings,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Answers by
Jeff
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or