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

LoadOnDemand with selectedValue

19 Answers 505 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
KMac
Top achievements
Rank 1
KMac asked on 10 Jun 2010, 04:43 PM
Hello,

I think I'm missing something here. I have a combobox that allows me to edit a column in a radGrid. The combobox has EnableLoadOnDemand = true because the datasource this is wired to has over 30000 records. When I go to edit an already created record, I get a Selection out of range Parameter name: value error. I'm assuming this is because the selectedValue isn't in the initial list, but how do I get that into the initial list. I'm also hoping to preload a small subset of the 30000 records into the combobox but it's not a necessity. My code is below:
ASPX
<telerik:GridTemplateColumn UniqueName="ProfileColumn" HeaderText="Name">  
            <EditItemTemplate> 
                 <telerik:RadComboBox ID="RadComboBox1" runat="server" Width="250px" Height="150px" 
                    EmptyMessage="--Select A Person--" EnableLoadOnDemand="True" ShowMoreResultsBox="True" 
                    EnableVirtualScrolling="True"   
                     OnItemsRequested="RadComboBox1_ItemsRequested"   
                      AppendDataBoundItems="False"   
                      DataTextField="fullname" DataValueField="profileID" SelectedValue='<%# Bind("profileID") %>' > 
                </telerik:RadComboBox>            
            </EditItemTemplate> 
            <ItemTemplate> 
                <asp:Label runat="server" Text='<%#Eval("CF_Person.lastName") %>'></asp:Label> 
            </ItemTemplate> 
        </telerik:GridTemplateColumn> 

Codebehind
 protected void RadComboBox1_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)  
    {  
        DataClassesDataContext db = new DataClassesDataContext();  
        var peoplefrom person in db.CF_People  
                       where person.firstName.Contains(e.Text) || person.lastName.Contains(e.Text)   
                       orderby person.lastName  
                       select person;  
 
            RadComboBox myComboBox = (RadComboBox)o;  
            myComboBox.Items.Clear();  
 
            myComboBox.ClearSelection();  
            foreach (var p in people)  
            {  
                myComboBox.Items.Add(new RadComboBoxItem(p.firstName + " " + p.lastName, p.profileID.ToString()));  
            }  
    }  
 
 
 
    protected void LinqProfile_Selecting(object sender, LinqDataSourceSelectEventArgs e)  
    {  
        DataClassesDataContext db = new DataClassesDataContext();  
        e.Result = (from person in db.People  
                      where person.firstName.StartsWith("A")  
                     orderby lawyer.lastName  
                     select new { fullname = (person.firstName + " " + person.lastName), person.firstName, person.lastName, person.profileID }).Take(20);  
    } 

Thanks in advance

19 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 14 Jun 2010, 04:54 PM
Hello KMac,

Indeed this happens because the value in that column of the row does not exist in the RadComboBox as it is loading Items on demand and is empty on the server.

You can workaround this by handling the RowDataBound event of the Grid and manually add this Item to the RCB so that it is pre-loaded when editing a record.

All the best,
Simon
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.
0
Ulrich
Top achievements
Rank 1
answered on 16 Jun 2010, 12:55 PM
Hello,

I face a similar problem.

What I currently do is I add the Item to the list exactly how you described it, but then the list only has one item, and the user has to click on the arrow on bottom to make the list trigger it's load on demand.

Is there a workaround for this?

best regards

Ulrik
0
Simon
Telerik team
answered on 17 Jun 2010, 09:27 AM
Hello Ulrich,

Yes, you can do the following:

  1. Add an attribute to the RadComboBox when you are adding this 'default' Item - RadComboBox.Attributes.Add("DefaultItem", "true");
  2. Handle the client-side DropDownOpening event in this way:
    function onDropDownOpening(sender) {
        var attributes = sender.get_attributes();
        if (attributes.getAttribute("DefaultItem") == "true") {
            sender.requestItems("", false);
            attributes.setAttribute("DefaultItem", "false");
        }
    }


Briefly, this approach will set a flag whenever you have the default Item in the RCB, and will trigger a request for Items on the first drop down opening. If you call requestItems with true as the second parameter, the new Items will be appended to the default Item.

Please let me know if you have additional questions.

Regards,
Simon
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
0
Ulrich
Top achievements
Rank 1
answered on 17 Jun 2010, 11:40 AM
That worked like a charm :)

Thank you very much!


0
JSON
Top achievements
Rank 1
answered on 13 Jul 2010, 06:28 PM
Hello,

I also have a similar issue using Load on Demand in a ComboBox. My code appears to retrieve matching results using Autocomplete functionality, yet nothing is displayed in the combobox. I can even make a selection that populated - just not initially visible?

Also, could you supply or point me to an example of the [RadComboBox - RowDataBound] event code to populate with a pre-existing value.

Thank you,

Steve O.

ASPX Code
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

<telerik:GridTemplateColumn DataField="UnitLeaderId"

 

 

 

UniqueName="UnitLeaderId" HeaderText="Unit Leader">

 

 

 

<EditItemTemplate>

 

 

 

<telerik:RadComboBox ID="rcbUnitLeader"

 

 

 

runat="server"

 

 

 

AutoPostBack="true"

 

 

 

HighlightTemplatedItems="true"

 

 

 

DropDownWidth="350px"

 

 

 

EnableLoadOnDemand="true"

 

 

 

EnableVirtualScrolling="true"

 

 

 

ShowMoreResultsBox="true"

 

 

 

EmptyMessage="Select Unit Leader"

 

 

 

OnItemsRequested="UnitLeader_ItemsRequested"

 

 

 

Height="200px">

 

 

 

 

<HeaderTemplate>

 

 

 

<table style="width: 250px; text-align: left;">

 

 

 

<tr>

 

 

 

<td style="width: 200px;">Name</td>

 

 

 

<td style="width: 50px;">Agency</td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</HeaderTemplate>

 

 

 

<ItemTemplate>

 

 

 

<table style="width: 250px; text-align: left; white-space:nowrap">

 

 

 

<tr>

 

 

 

<td style="width: 200px;"><%# DataBinder.Eval(Container.DataItem, "Name") %></td>

 

 

 

<td style="width: 50px;"><%# DataBinder.Eval(Container.DataItem, "Agency") %></td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</ItemTemplate>

 

 

 

 

</telerik:RadComboBox>

 

 

 

</EditItemTemplate>

 

 

 

</telerik:GridTemplateColumn>

 

 


Code Behind
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

private static DataTable GetData(string text, string qry)

 

{

 

 

SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CIMT"].ConnectionString);

 

 

 

SqlDataAdapter da = new SqlDataAdapter(qry,conn);

 

da.SelectCommand.Parameters.AddWithValue(

 

"@pText", text);

 

 

 

DataTable data = new DataTable();

 

da.Fill(data);

 

 

return data;

 

}

 

 

 

 

 

protected void UnitLeader_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)

 

{

 

 

GridEditableItem editedItem = (sender as RadComboBox).NamingContainer as GridEditableItem;

 

 

 

string qry = "SELECT RTRIM(Name) Name, Agency FROM CIMT_V_Resources WHERE Name LIKE @pText + '%' ORDER BY 1";

 

 

 

DataTable data = GetData(e.Text, qry);

 

 

 

int itemOffset = e.NumberOfItems;

 

 

 

int endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count);

 

e.EndOfItems = endOffset == data.Rows.Count;

 

 

for (int i = itemOffset; i < endOffset; i++)

 

{

 

 

RadComboBox rcb = (RadComboBox)editedItem.FindControl("rcbUnitLeader");

 

 

 

if (rcb != null)

 

{

rcb.Items.Add(

 

new RadComboBoxItem(data.Rows[i]["Name"].ToString(), data.Rows[i]["Agency"].ToString()));

 

}

}

e.Message = GetStatusMessage(endOffset, data.Rows.Count);

}

 

0
Simon
Telerik team
answered on 14 Jul 2010, 01:18 PM
Hello JSON,

You need to call the DataBind method for each Item created manually in the ItemsRequested event handler in order to apply the data binding expressions in the Template as shown in this demo (the first RadComboBox).

As for your second question, could you please clarify what do you mean by "[RadComboBox - RowDataBound] event code"?

Kind regards,
Simon
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
0
JSON
Top achievements
Rank 1
answered on 14 Jul 2010, 02:06 PM
In my second question, I need to know how to load a pre-existing values in the combobox in Edit Mode. You said to "call databind method for each item created manually in the ItemsRequested" event handler in order to apply the data binding expressions". The actions I am trying to accomplish happen when a pre-existing row is initially selected for Edit and not when items are being requested. Would please describe in detail how I am to construct the data binding event to accomplish this.

Thank you,

Steve O.
0
JSON
Top achievements
Rank 1
answered on 16 Jul 2010, 04:18 PM
Hello,

I am still waiting for a reply of my last post. I am under a dead-line and need some help ASAP.

Again, I have a Combo Box using Load on Demand for performance that needs to display pre-existing values in Edit Mode. When the grid is expanded, the values are displayed, yet in Edit Mode - the combo boxes are empty.

In your last reply, I was instructed to subscribe to a Data Bind event, but I need an example of what specifically needs to be done. In the mean time I am trying to get this working, but cannot - and need your assistance.

Your expeditious response is appreciated.

Thank you,

Steve O.
Orange County Sheriff's Office

 

<telerik:GridTemplateColumn DataField="UnitLeader"

 

 

 

UniqueName="UnitLeader"

 

 

 

HeaderText="Unit Leader">

 

 

 

<ItemTemplate>

 

 

<%

# Eval("UnitLeader")%>

 

 

 

</ItemTemplate>

 

 

 

<HeaderStyle Font-Bold="True"></HeaderStyle>

 

 

 

<ItemStyle Wrap="false" />

 

 

 

<EditItemTemplate>

 

 

 

<telerik:RadComboBox ID="rcbUnitLeader"

 

 

 

runat="server"

 

 

 

AutoPostBack="true" DataTextField="UnitLeader" DataValueField="UnitLeader"

 

 

 

MarkFirstMatch="true"

 

 

 

HighlightTemplatedItems="true"

 

 

 

DropDownWidth="350px"

 

 

 

EnableLoadOnDemand="true"

 

 

 

EnableVirtualScrolling="true"

 

 

 

ShowMoreResultsBox="true"

 

 

 

EmptyMessage="Select Unit Leader"

 

 

 

OnItemsRequested="UnitLeader_ItemsRequested"

 

 

 

Height="200px">

 

 

 

 

<HeaderTemplate>

 

 

 

<table style="width: 250px; text-align: left;">

 

 

 

<tr>

 

 

 

<td style="width: 200px;">Name</td>

 

 

 

<td style="width: 50px;">Agency</td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</HeaderTemplate>

 

 

 

<ItemTemplate>

 

 

 

<table style="width: 250px; text-align: left; white-space:nowrap">

 

 

 

<tr>

 

 

 

<td style="width: 200px;"><%# DataBinder.Eval(Container.DataItem, "Name") %></td>

 

 

 

<td style="width: 50px;"><%# DataBinder.Eval(Container.DataItem, "Agency") %></td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</ItemTemplate>

 

 

 

 

</telerik:RadComboBox>

 

 

 

</EditItemTemplate>

 

 

 

<FooterTemplate>No matches

 

 

 

<asp:Literal runat="server" ID="UnitLeaderCount" />

 

 

 

</FooterTemplate>

 

 

 

</telerik:GridTemplateColumn>

 

 

0
Simon
Telerik team
answered on 16 Jul 2010, 05:51 PM
Hello JSON,

Thank you for the details.

You can find the RadComboBox in the Grid's ItemDataBound event as shown in this help article. The approach is the same as in the article you only need to substitute the DropDownList with a RCB.

I hope this helps and is on time. Please let me know if you have further questions.

Regards,
Simon
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
0
JSON
Top achievements
Rank 1
answered on 16 Jul 2010, 07:20 PM
Hello,

Yes, thanks for your quick reply.

I appears my issue is not being understood correctly.

In a detail RadGrid view - bound to a Sql Data Source, when a record is selected for editing, the combo box control's value in Edit Mode is not displayed. Why is this not working and how do I resolve this problem.

I can get the value displayed using two-way bindinding but because the combo box is populated by load on demand, an error is raised stating this can only be done on a bound control.

How do I show bound values in a combo box when a detail RadGrid view record is in Edit Mode? I have spent several days on blogs and forums looking for an answer with no luck.

Thank you,

Steve O.

 

<DetailTables>

 

 

<telerik:GridTableView DataKeyNames="UnitLogId"

 

 

Name="UnitLogs"

 

 

Width="100%"

 

 

Caption="<br/><h3><b>Unit Logs</b></h3>"

 

 

GridLines="Both"

 

 

EditMode="EditForms"

 

 

DataSourceID="SqlDataSource12"

 

 

BorderStyle="Solid"

 

 

BorderWidth="1px"

 

 

BorderColor="Blue"

 

 

CommandItemDisplay="Top"

 

 

ExpandCollapseColumn-ButtonType="ImageButton"

 

 

ExpandCollapseColumn-CollapseImageUrl="~/Images/zoom-out-icon[1].png"

 

 

ExpandCollapseColumn-ExpandImageUrl="~/Images/zoom-in-icon[1].png">

 

 

 

<ParentTableRelation>

 

 

<telerik:GridRelationFields MasterKeyField="UnitId" DetailKeyField="UnitId" />

 

 

</ParentTableRelation>

 

 

 

<ExpandCollapseColumn Visible="True" ItemStyle-Wrap="false"></ExpandCollapseColumn>

 

 

<EditFormSettings>

 

 

<EditColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"

 

 

CancelImageUrl="~/Images/filterCancel.png"

 

 

UpdateImageUrl="~/Images/selecttag.png"

 

 

InsertImageUrl="~/Images/selecttag.png"

 

 

EditImageUrl="~/Images/edit-icon[1].png">

 

 

</EditColumn>

 

 

</EditFormSettings>

 

 

<Columns>

 

 

<telerik:GridTemplateColumn DataField="UnitLeader"

 

 

UniqueName="UnitLeader"

 

 

HeaderText="Unit Leader">

 

 

<ItemTemplate>

 

<%

# Eval("UnitLeader")%>

 

 

</ItemTemplate>

 

 

<HeaderStyle Font-Bold="True"></HeaderStyle>

 

 

<ItemStyle Wrap="false" />

 

 

<EditItemTemplate>

 

 

<telerik:RadComboBox ID="rcbUnitLeader"

 

 

runat="server"

 

 

AutoPostBack="true"

 

 

MarkFirstMatch="true"

 

 

HighlightTemplatedItems="true"

 

 

DropDownWidth="350px"

 

 

EnableLoadOnDemand="true"

 

 

EnableVirtualScrolling="true"

 

 

ShowMoreResultsBox="true"

 

 

EmptyMessage="Select Unit Leader"

 

 

OnItemsRequested="UnitLeader_ItemsRequested"

 

 

Height="200px">

 

 

 

<HeaderTemplate>

 

 

<table style="width: 250px; text-align: left;">

 

 

<tr>

 

 

<td style="width: 200px;">Name</td>

 

 

<td style="width: 50px;">Agency</td>

 

 

</tr>

 

 

</table>

 

 

</HeaderTemplate>

 

 

<ItemTemplate>

 

 

<table style="width: 250px; text-align: left; white-space:nowrap">

 

 

<tr>

 

 

<td style="width: 200px;"><%# DataBinder.Eval(Container.DataItem, "Name") %></td>

 

 

<td style="width: 50px;"><%# DataBinder.Eval(Container.DataItem, "Agency") %></td>

 

 

</tr>

 

 

</table>

 

 

</ItemTemplate>

 

 

 

</telerik:RadComboBox>

 

 

</EditItemTemplate>

 

 

<FooterTemplate>No matches

 

 

<asp:Literal runat="server" ID="UnitLeaderCount" />

 

 

</FooterTemplate>

 

 

 

</telerik:GridTemplateColumn>

 

0
Simon
Telerik team
answered on 19 Jul 2010, 01:59 PM
Hello JSON,

You can find the RadComboBox when in EditMode in the same way a DropDownList is found in the help article I have you a link to previously.

What you need to do then is to extract the Value from the DataItem of the Grid Row, create an Item and add it in the RCB. In this way, you will populate the RCB in EditMode with a pre-loaded Item.

I hope this helps.

All the best,
Simon
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
0
JSON
Top achievements
Rank 1
answered on 19 Jul 2010, 03:06 PM

Hello,

Again I will try to better explain what I am doing. The examples provided i.e help article; are too generalized and are of no help.

I have access to the controls in the ItemDataBound event but the OnUpdateCommand event is not firing when the Edit Command is selected, similar to your example where the bound values are placed in session variables.

I have included a screen shot displaying what I am describing here.

Please understand I am basically new at using Telerik controls and need more detailed help and examples on how to solve these issues.


Thank you,

Steve O...

 

<telerik:RadGrid ID="RadGrid2"

 

 

 

 

runat="server"

 

 

 

 

GridLines="None"

 

 

 

 

DataSourceID="SqlDataSource11"

 

 

 

 

OnPageIndexChanged="dgIncidents_PageIndexChanged"

 

 

 

 

AllowAutomaticDeletes="True"

 

 

 

 

AllowAutomaticInserts="True"

 

 

 

 

AllowAutomaticUpdates="True"

 

 

 

 

AllowPaging="True"

 

 

 

 

ShowStatusBar="True"

 

 

 

 

OnItemInserted="RadGrid2_ItemInserted"

 

 

 

 

OnItemCreated="RadGrid2_ItemCreated"

 

 

 

 

OnItemUpdated="RadGrid2_ItemUpdated"

 

 

 

 

OnInsertCommand="RadGrid2_ItemInsert"

 

 

 

 

OnUpdateCommand="RadGrid2_ItemUpdate"

 

 

 

 

OnItemCommand="RadGrid2_ItemCommand"

 

 

 

 

OnItemDataBound="RadGrid2_ItemDataBound"

 

 

 

 

AutoGenerateColumns="False"

 

 

 

 

Skin="Simple" >

 

 

 

 

<ValidationSettings EnableValidation="true" ValidationGroup="DropDownValidate" />

 

 

 

 

<%

-- Incidents --%>

 

 

 

 

<MasterTableView runat="server"

 

 

 

 

Name="Incidents"

 

 

 

 

Caption="<br/><h3><b>Incidents</b></h3>"

 

 

 

 

DataSourceID="SqlDataSource11"

 

 

 

 

DataKeyNames="IncidentID"

 

 

 

 

CommandItemDisplay="Top"

 

 

 

 

EditMode="InPlace"

 

 

 

 

GridLines="Both"

 

 

 

 

HeaderStyle-Font-Bold="true"

 

 

 

 

ExpandCollapseColumn-ButtonType="ImageButton"

 

 

 

 

ExpandCollapseColumn-CollapseImageUrl="~/Images/zoom-out-icon[1].png"

 

 

 

 

ExpandCollapseColumn-ExpandImageUrl="~/Images/zoom-in-icon[1].png"

 

 

 

 

InsertItemPageIndexAction="ShowItemOnCurrentPage" >

 

 

 

 

<RowIndicatorColumn>

 

 

 

 

<HeaderStyle Width="20px" Font-Bold="true"></HeaderStyle>

 

 

 

 

</RowIndicatorColumn>

 

 

 


<
DetailTables>
    <telerik:GridTableView  DataKeyNames="UnitLogId" 
                            Name="UnitLogs" 
                            Width="100%" 
                            Caption="<br/><h3><b>Unit Logs</b></h3>"   
                            GridLines="Both"
                            EditMode="EditForms"
                            DataSourceID="SqlDataSource1"
                            BorderStyle="Solid" 
                            BorderWidth="1px" 
                            BorderColor="Blue"
                            CommandItemDisplay="Top"
                            ExpandCollapseColumn-ButtonType="ImageButton"
                            ExpandCollapseColumn-CollapseImageUrl="~/Images/zoom-out-icon[1].png"    
                            ExpandCollapseColumn-ExpandImageUrl="~/Images/zoom-in-icon[1].png">
                              
        <ParentTableRelation>
            <telerik:GridRelationFields MasterKeyField="UnitId" DetailKeyField="UnitId" />
        </ParentTableRelation>
          
        <ExpandCollapseColumn Visible="True" ItemStyle-Wrap="false"></ExpandCollapseColumn>
         <EditFormSettings>
          <EditColumn   UniqueName="EditCommandColumn" ButtonType="ImageButton"   
                        CancelImageUrl="~/Images/filterCancel.png"
                        UpdateImageUrl="~/Images/selecttag.png" 
                        InsertImageUrl="~/Images/selecttag.png" 
                        EditImageUrl="~/Images/edit-icon[1].png">
          </EditColumn>
         </EditFormSettings>
        <Columns>
             
           <telerik:GridTemplateColumn  DataField="UnitLead" 
                                        UniqueName="UnitLead" 
                                        HeaderText="Unit Leader">
                <ItemTemplate>
                    <%# Eval("UnitLead")%>
                </ItemTemplate>
                <HeaderStyle Font-Bold="True"></HeaderStyle>
                <ItemStyle Wrap="false" />
                <EditItemTemplate>
                    <telerik:RadComboBox    ID="rcbUnitLeader"
                                            runat="server"
                                            AutoPostBack="true" 
                                            MarkFirstMatch="true"
                                            HighlightTemplatedItems="true" 
                                            DropDownWidth="350px" 
                                            EnableLoadOnDemand="true"
                                            EnableVirtualScrolling="true"
                                            ShowMoreResultsBox="true"
                                            EmptyMessage="Select Unit Leader"
                                            OnItemsRequested="UnitLeader_ItemsRequested"
                                            Height="200px">
                     
                                            <HeaderTemplate>
                                            <table style="width: 250px; text-align: left;">
                                                    <tr>
                                                        <td style="width: 200px;">Name</td>
                                                        <td style="width: 50px;">Agency</td>
                                                    </tr>
                                                </table>
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <table style="width: 250px; text-align: left; white-space:nowrap">
                                                    <tr>
                                                        <td style="width: 200px;"><%# DataBinder.Eval(Container.DataItem, "Name") %></td>
                                                        <td style="width: 50px;"><%# DataBinder.Eval(Container.DataItem, "Agency") %></td>
                                                    </tr>
                                                </table>
                                            </ItemTemplate>
       
                   </telerik:RadComboBox>
                </EditItemTemplate>
                <FooterTemplate>No matches
                    <asp:Literal runat="server" ID="UnitLeaderCount" />                
                </FooterTemplate>
           </telerik:GridTemplateColumn>
            <telerik:GridDateTimeColumn DataField="UnitStartDate" DataType="System.DateTime" 
                HeaderText="Operation Start Date" ItemStyle-Wrap="false" HeaderStyle-Wrap="false" SortExpression="UnitStartDate" 
                UniqueName="UnitStartDate" PickerType="DateTimePicker" >
            <HeaderStyle Font-Bold="True" Wrap="false"></HeaderStyle>
            <ItemStyle Wrap="False" Width="200"></ItemStyle>
            </telerik:GridDateTimeColumn>
              
            <telerik:GridDateTimeColumn DataField="UnitEndDate" DataType="System.DateTime" 
                HeaderText="Operation End Date" SortExpression="UnitEndDate" 
                UniqueName="UnitEndDate" PickerType="DateTimePicker" ItemStyle-Wrap="false" HeaderStyle-Wrap="false">
            <ItemStyle Wrap="False" Width="200"></ItemStyle>
            <HeaderStyle Font-Bold="True" Wrap="false"></HeaderStyle>
            </telerik:GridDateTimeColumn>
              
            <telerik:GridTemplateColumn DataField="PrepBy" 
                                        UniqueName="PrepBy" 
                                        HeaderText="Prepared By">
                <ItemTemplate>
                    <%# Eval("PrepBy")%>
                </ItemTemplate>
                <HeaderStyle Font-Bold="True"></HeaderStyle>
                <ItemStyle Wrap="false" />
                <EditItemTemplate>
                    <telerik:RadComboBox    ID="rcbPreparedBy"
                                            runat="server" 
                                            AutoPostBack="true"
                                            HighlightTemplatedItems="true" 
                                            MarkFirstMatch="true" 
                                            DropDownWidth="350px" 
                                            EnableLoadOnDemand="true" 
                                            EnableVirtualScrolling="true"
                                            ShowMoreResultsBox="true"
                                            EmptyMessage="Select Prepared By" 
                                            OnItemsRequested="PreparedBy_ItemsRequested"
                                            Height="400px">
                     
                                            <HeaderTemplate>
                                            <table style="width: 250px; text-align: left">
                                                    <tr>
                                                        <td style="width: 200px;">Prepared By</td>
                                                    </tr>
                                                </table>
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <table style="width: 250px; text-align: left">
                                                    <tr>
                                                        <td style="width: 200px;"><%# DataBinder.Eval(Container.DataItem, "Name") %></td>
                                                    </tr>
                                                </table>
                                            </ItemTemplate>
       
                   </telerik:RadComboBox>
                </EditItemTemplate>
                <FooterTemplate>No matches
                    <asp:Literal runat="server" ID="PreparedByCount" />                
                </FooterTemplate>
           </telerik:GridTemplateColumn>

 

protected void RadGrid2_EditCommand(object sender, GridCommandEventArgs e)

 

{

 

GridEditableItem editedItem = e.Item as GridEditableItem;

 

 

RadComboBox rcb;

 

rcb = editedItem.FindControl(

"rcbUnitLeader") as RadComboBox;

 

Session[

"unitLeadValue"] = rcb.SelectedValue;

 

rcb = editedItem.FindControl(

"rcbPreparedBy") as RadComboBox;

 

Session[

"prepByValue"] = rcb.SelectedValue;

 

}

 

protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)

 

{

 

string tabName = e.Item.OwnerTableView.Name.ToString();

 

 

if (e.Item is GridEditableItem && e.Item.IsInEditMode)

 

{

 

GridEditableItem editItem = (GridEditableItem)e.Item;

 

 

RadComboBox rcb;

 

 

switch (tabName)

 

{

 

case "UnitLogs":

 

rcb = (

RadComboBox)editItem.FindControl("rcbUnitLeader");

 

rcb.Text = Session[

"unitLeadValue"].ToString();

 

rcb = (

RadComboBox)editItem.FindControl("rcbPreparedBy");

 

rcb.Text = Session[

"prepByValue"].ToString();

 

 

break;

 

 

case "Rosters":

 

rcb = (

RadComboBox)editItem.FindControl("rcbRosterResource");

 

rcb.Text =

"Roster";

 

 

break;

 

 

default:

 

 

break;

 

}

}

}

0
JSON
Top achievements
Rank 1
answered on 20 Jul 2010, 07:22 PM
Please can I get a response to my post that is now 24 hours old!
0
Simon
Telerik team
answered on 21 Jul 2010, 05:09 PM
Hello JSON,

The UpdateCommand event fires when the currently edited Row is submitted for update, e.g. via an OK/Update button in the Edit Template. Please try moving the code that is now in your EditCommand event handler to the UpdateCommand one.

If this does not help, please open a support ticket and send the page you are working on there. We will modify it accordingly to make it work and will get back to you.

Kind regards,
Simon
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
0
Ulrich
Top achievements
Rank 1
answered on 22 Sep 2010, 10:23 AM
Hello,

I have to ask a question in this topic again, and I am not perfectly sure if the problem I am facing now came with the Q2 2010 Release or if I (or the frontend users) never noticed it, which I doubt.

I am using a radcombobox with virtual scrolling, and when setting a value I am setting the flag "defaultitem" to true and handle the ondropdownopening like it is mentioned above.

This works, BUT everytime data is queried while scrolling, the defaultitem is added along with the new Data.

Let's say I set Item "M" as default item, and I query the alphabet from the database with a pagesize of 10

When the combobox is closed, it displays "M". I open the combobox, and the first ten letters of the alphabet are display, along with "M" at the top (this is what I intend).

As soon as I scroll past the tenth letter, and the following ten are populated to the combobox, it actually is populated with eleven items, the first again beeing "M", so my comboxbox looks something like this:

M
A
B
C
D
F
G
H
I
J
K
M <---
L
M
O
P
Q
R
S
T
U
V
M <---
W
X
Y
Z

Is this a known problem or is there any whay to work around this problem?

best regards

Ulrik
0
Simon
Telerik team
answered on 23 Sep 2010, 03:05 PM
Hi Ulrich,

This is so because the Item gets added to the RadComboBox on each Page load. Since the control appends the newly added Item to its existing list the Item is duplicated.

You can resolve this if you add the Item *only if* the number of Items in the RCB is 0 (in the ItemsRequested event handler by using e.NumberOfItems).

I hope this helps.

All the best,
Simon
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
0
Ulrich
Top achievements
Rank 1
answered on 23 Sep 2010, 04:42 PM
Hello Simon,

thank you for the response! Actually, that was the first thing I thought off, and I am quite sure I already checked if the default item is added more than once, but I will check my code again to make sure and report back if this solved the problem.

best regards

Ulrik
0
vijaya kumar
Top achievements
Rank 1
answered on 05 Jan 2011, 08:54 PM
Hi,

I have similar issue, i have a rad combobox with autocomplete, Autocomplete functionality is working files. here the problem is, when i comes to this page in edit mode the radcombobox is not getting selected with the previous value saved, but it showing by default first value in the combox

I have set the property EnableLoadOnDemand=true, if it is set false the dropdown is geting selected  the previously saved value but  here the auto fill search is not loading

Code

In c#  cmbCounty.selectedvalue=countryid i am passing, but it is not getting selected.

<telerik:RadComboBox ID="cmbCountry" runat="server" EnableEmbeddedSkins="false" HighlightTemplatedItems="true" MaxHeight="200px"

Skin="NextGen" BorderStyle="None" Width="153px" MarkFirstMatch="true" AllowCustomText="false" AutoPostBack="false"

CssClass="cmb_AutoCompleteDropDown" EnableEmbeddedBaseStylesheet="false" ShowDropDownOnTextboxClick="false" ShowMoreResultsBox="false"

EnableVirtualScrolling="false" RadComboBoxImagePosition="right"

ShowToggleImage="true"

EnableItemCaching="true"

OnClientDropDownOpening="onDropDownOpening"

ToolTip="Countries"

OnClientBlur="AutoCompleteResetSearchEngagementFlag"

EnableLoadOnDemand="true"

OnItemsRequested="ucAutoComplete_ItemsRequested" StartSearchAt="2">

</telerik:RadComboBox>

function AutoCompleteBlockClientUpdates(sender, eventArgs) {

var startSearchAt = sender._attributes.getAttribute("StartSearchAt");

if (!startSearchAt) { startSearchAt = 3; }

if (sender.get_text().length < startSearchAt && !sender.serachEngaged) {

eventArgs.set_cancel(true);

}

else {

sender.serachEngaged = true;

eventArgs.set_cancel(false);

}

}

function AutoCompleteResetSearchEngagementFlag(sender, args) {

sender.serachEngaged = false;

}

function AutoCompleteHideDropDownIfEmpty(combobox) {

if (combobox.get_items().get_count() === 0) {

combobox._hideDropDown();

}

}

function onDropDownOpening(sender)

{

debugger;

var attributes = sender.get_attributes();

if(attributes.getAttribute("DefaultItem") == "true")

{

sender.requestItems("",false);

attributes.setAttribute("DefaultItem", "false");

}

}


Please help me out on this

0
Andrew W
Top achievements
Rank 1
answered on 22 Nov 2011, 09:36 PM
I got the same issue. My default item is added every time I fetch new set of records. It looks that RadComboBox.Items.Add() method keep adding it.

Andrew
Tags
ComboBox
Asked by
KMac
Top achievements
Rank 1
Answers by
Simon
Telerik team
Ulrich
Top achievements
Rank 1
JSON
Top achievements
Rank 1
vijaya kumar
Top achievements
Rank 1
Andrew W
Top achievements
Rank 1
Share this question
or