EnableLoadOnDemand When Editing.

11 posts, 0 answers
  1. Craig Hinkel
    Craig Hinkel avatar
    36 posts
    Member since:
    May 2008

    Posted 17 Dec 2008 Link to this post

    I'm using the radcombox in one of my form templates with the EnableLoadOnDemand turned on. I was wondering how do you handle the situation when in edit mode and you need to select an item for an existing record? For example, I use a StatusID for the data value and the StatusNm for the text display (which is a concatenation of two columns from the table). I saw an example where you dont use ID's, but rather the name for the value and text and this is not an option in our real world.

    Thanks
  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 18 Dec 2008 Link to this post

    Hello Craig Hinkel,

    Could you clarify what do you mean by "edit mode"?

    Please provide more information about your goal.

    Thank you in advance.

    Sincerely yours,
    Simon
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Craig Hinkel
    Craig Hinkel avatar
    36 posts
    Member since:
    May 2008

    Posted 18 Dec 2008 Link to this post

    I simply mean selecting a default value (for example, editing a customer record).
  4. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 20 Dec 2008 Link to this post

    Hi Craig Hinkel,

    You could use the <%# Bind %> expression to bind the SelectedValue property of the ComboBox, which is inside the Template, to a field in the data source.

    Please see this Code Library Project for an example of a RadComboBox inside Edit and Insert Templates of a FormView.

    Regards,
    Simon
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Craig Hinkel
    Craig Hinkel avatar
    36 posts
    Member since:
    May 2008

    Posted 05 Jan 2009 Link to this post

    If I set the SelectedValue to say 5, how is the loadondemand going to work then since it uses the typed in text? I only allow the webservice to be called when the text is not equal to an empty string. does that make sense?
  6. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 08 Jan 2009 Link to this post

    Hello Craig Hinkel,

    When binding the Grid you could create and add each RadComboBox Item with the data coming from the data base.

    Further when you start typing in the ComboBox it will call the Web Service to load new Items.

    Both functionalities should not interfere with each other.

    Please let me know if I have missed something.

    All the best,
    Simon
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Craig Hinkel
    Craig Hinkel avatar
    36 posts
    Member since:
    May 2008

    Posted 08 Jan 2009 Link to this post

    I'm sorry, I do not think I am explaining my use case properly. Let me start over :)

     I have a screen used for editing and adding orders. There is a radcombobox control that loads a list of customers using loading on demand. When I load the radcombobox, I use the customers first name, lastname, and email as the display text and the customer id as the value.

    Here is where the problem lies. When "editing" an existing order, I need to select the appropriate customer in the radcombobox, but it seems very code smelly to take the orders customer id, find the customer, then concatenate first name, lastname, and email and set the radcombobox's text property.

    Does this make more sense?
  8. Celestyn
    Celestyn avatar
    4 posts
    Member since:
    Oct 2008

    Posted 09 Jan 2009 Link to this post

    Thanks. What a simple solution. I still searched for some complicated coding.

    Now I add

    ... AppendDataBoundItems="True" ...

    and

    <

    Items>

     

     

    <telerik:RadComboBoxItem Value="current key of binded field" Text="current value" Selected="True" />

     

     

    </Items>

    and it works like a charm.

     

  9. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 10 Jan 2009 Link to this post

    Hi Craig Hinkel,

    Thank you for clarifying.

    In this case I suggest you use the following approach: in case the page is opened for edit and the Customer Id is supplied, simply load the necessary Items (or just that of the current Customer) on the server and display it in the ComboBox.

    In this way, you will have both the edited Customer selected and the Load on Demand functionality available at the same time.

    Regards,
    Simon
  10. cheburek
    cheburek avatar
    25 posts
    Member since:
    May 2009

    Posted 27 Aug 2010 Link to this post

    Hi Simon
    I know that this thread is quite old but it is still actual.
    Could you please provide a little example on that (bind default value for combobox on page load, where text is of type System.String and value is integer ID)?
    I.e. a sample code with desired functionality on edit screen

    <asp:TextBox Id="tbCode" runat="server" Text='<%# Bind("Code") %>' />
    <telerik:RadComboBox runat="server" Id="cbCustomer"
    SelectedValue='<%# Bind("CustomerId") %>'
    Filter="Contains" EnableLoadOnDemand="True">
    <WebServiceSettings Path="~/AppCode/myService.asmx" Method="ReportCustomerList" />
    </telerik:RadComboBox>
    <asp:ObjectDataSource ID="dataTableSrc" runat="server" SelectMethod="Collect"
        TypeName="MyProjectNamespace.DatamanagerClass"
        InsertMethod="Insert" UpdateMethod="Update">
        <InsertParameters>
            <asp:Parameter Name="Code" Type="String" />
            <asp:Parameter Name="CustomerId" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="Code" Type="String" />
            <asp:Parameter Name="CustomerId" Type="Int32" />
        </UpdateParameters>
    </asp:ObjectDataSource>

    Thanks in advance
  11. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 27 Aug 2010 Link to this post

    Hi cheburek,

    Please see this Code Library Project for more information and a lot of sample code. I believe it will get you on the right track.

    Sincerely yours,
    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
Back to Top