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

Adding items to listbox with ClientItemTemplate and ClientDataSource

2 Answers 83 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Omar
Top achievements
Rank 1
Omar asked on 03 Nov 2016, 11:47 AM

I'm trying to add data/item to a listbox with custom ClientItemTemplate where I'm not using Text or Value but using other variables.

<telerik:RadListBox ID="AlarmListBox" runat="server" Height="100%" Width="100%" RenderMode="Lightweight" ClientDataSourceID="AlarmClientDataSource" OnClientSelectedIndexChanged="OnListItemSelected">   
    <EmptyMessageTemplate>
        <asp:Label runat="server" Text="No Alerts"></asp:Label>
    </EmptyMessageTemplate>
     <ClientItemTemplate>
          <div class="alarm">
            <div class="alarm-wrapper">
                <img src="#: src #" class="img-responsive alarm-list-image" style="float: left" ;/>
                <dl class="alarm-list-details">
                    <dt class="name">#= type #</dt>
                </dl>
                <div style="clear: left" />
                </div>
            </div>
    </ClientItemTemplate>
</telerik:RadListBox>

At first, I was using the listbox without a data source and I was able to add to the data by setting the attributes of a new listboxitem from the client-side.

Then I wanted to use a dummy REST service to test populating results.

I was able to populate the listbox using the clientdatasource using "select" only.

Now I want to be able to use both functionality, to populate the listbox from the REST service and manually. I tried to add directly to the listbox but it failed because their is no attributes and when I added items to clientdatasource using add() method but the new item did not appear in listbox.

Which method of adding an item is correct bearing in mind that I want to update the results to the REST service eventually and how can it be done.

2 Answers, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 08 Nov 2016, 08:57 AM
Hi Omar,

The appropriate approach for the discussed scenario is to first add the item to the ClientDataSource and then to rebind the RadListBox, so it displays the newly created item too. This, however, could not be achieved at the moment, as the RadListBox could not be rebound on the client. Therefore, we have included this functionality in our product backlog for future implementation. You will be able to track its status in our Feedback portal.

As a small token of gratitude for suggesting us this enhancement of the control functionality, I have updated your Telerik points.

In case you have any further questions, please do not hesitate to contact us.

Regards,
Veselin Tsvetanov
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
0
Omar
Top achievements
Rank 1
answered on 14 Nov 2016, 12:26 PM
Thank you for your reply
Tags
ListBox
Asked by
Omar
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Omar
Top achievements
Rank 1
Share this question
or