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

Text rendered not updated when using client-side set_text();

5 Answers 81 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Aaron Mell
Top achievements
Rank 1
Aaron Mell asked on 14 Apr 2010, 07:07 PM
I have the following javascript that is being called in the OnClientReordered event. I am trying to change the text of the items in the list when they are reordered. What I am seeing is the item does not update the first time the event fires. The second time the event fires the text gets rendered correctly. (The text is being changed properly, as I can put a watch on the values, and the text is correct. It is just not being rendered) Is there something I am doing incorrectly here? I could find no information from the documentation on the API.



function SetcontentorderNumber() { 
        reg = new RegExp("\\[\\d*\\]") 
        var list = $find("<%= foo.ClientID %>"); 
        var length = list.get_items().get_count(); 
 
        list.trackChanges(); 
        for (var i = 0; i < length; i++) { 
            var text = list.getItem(i).get_text(); 
            if (reg.test(text)) { 
                texttext = text.replace(reg, "[" + (i + 1) + "] "); 
                list.getItem(i).set_text(text); 
            } 
            else { 
                text = "[" + (i + 1) + "] " + text; 
                list.getItem(i).set_text(text); 
            } 
        } 
        list.commitChanges(); 
    } 

5 Answers, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 15 Apr 2010, 11:39 AM
Hello Aaron Mell,

The point is that OnClientReordered event fires when the reordering is just completed. However with changing to OnClientReordering the text will render correctly from the first time.

<telerik:RadListBox ID="RadListBox1" runat="server" OnClientReordering="SetcontentorderNumber" AllowReorder="true">
            <ButtonSettings ReorderButtons="Common"></ButtonSettings>
            <Items>
                <telerik:RadListBoxItem runat="server" Text="RadListBoxItem1" />
                <telerik:RadListBoxItem runat="server" Text="RadListBoxItem2" />
                <telerik:RadListBoxItem runat="server" Text="RadListBoxItem3" />
                <telerik:RadListBoxItem runat="server" Text="RadListBoxItem4" />
                <telerik:RadListBoxItem runat="server" Text="RadListBoxItem5" />
                <telerik:RadListBoxItem runat="server" Text="RadListBoxItem6" />
            </Items>
        </telerik:RadListBox>

You may find a sample project in the attached .zip file.

Hope this helps.

Best wishes,
Veronica Milcheva
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
Aaron Mell
Top achievements
Rank 1
answered on 15 Apr 2010, 03:11 PM
I tried the code both ways, using both the reordering, and the reordered event. Result is the same.
0
Veronica
Telerik team
answered on 15 Apr 2010, 04:49 PM
Hello Aaron Mell,

Here's the result when using the OnClientReordered event:


and the result with OnClientReordering:



Let me know if I am missing something.

Best wishes,
Veronica Milcheva
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
Aaron Mell
Top achievements
Rank 1
answered on 15 Apr 2010, 05:48 PM
Veronica,
I have identified the issue. It seems as though this issue is related to the version of the controls we are using. I tried the controls in a sample project with the newest controls, and it is working as expected. We cannot upgrade the controls at this time, but I will make note of it.
0
Veronica
Telerik team
answered on 16 Apr 2010, 08:38 AM
Hello Aaron Mell,

Please accept my apologies. I missed to write that I am using the latest version (2010.1.309) for the test.

I'm glad you discovered that the problem is in the versions.

Feel free to ask whenever you have other questions.

All the best,
Veronica Milcheva
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
ListBox
Asked by
Aaron Mell
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Aaron Mell
Top achievements
Rank 1
Share this question
or