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

OnRowCreated not raised on repaint

2 Answers 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 2
David asked on 14 Jun 2012, 05:00 PM
I am currently trying to make a popup editor work clientside with a backend WS, my problem is that when i add repaint the grid to show up the new items, the ids do not match up.

So i thought that i could set the ids on the rowcreated client event like so..

Code
...
           <ItemTemplate>
                <asp:label ID="ltrl_edit" runat="server"></asp:label>
           </ItemTemplate>
....
   function RowCreated(sender, eventArgs) {
                var cid = eventArgs.get_gridDataItem().getDataKeyValue("contactID");
                var imgstr = "<img src='../smtImages/ico_Editsm.png' style='cursor:pointer' class='hightlighttracklist' onclick='initialiseEdit(" + cid + ")' />"

                var item = eventArgs.get_gridDataItem();
                var button1 = $telerik.findElement(item.get_element(), "ltrl_edit");
                $(button1).html(imgstr);
            }

  1. My problem is that when I add an item and call the repaint method (with the new data), the RowCreated event is not fired
       
       function updateGrid(result) {
                   var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
                tableView.set_dataSource(result);
                tableView.dataBind();
                var grid = $find("<%= RadGrid1.ClientID %>");
                grid.repaint();
            }

Any workarounds to this would be a gratefully recieved.

Thanks

Dave

2 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 20 Jun 2012, 06:04 AM
Hello David,

The OnRowCreated event is fired after a row available at client-side is created, however in client side data binding all rows are created on the server side and bound to data on the client. If you change the data source of the RadGrid the new data will be bound to all rows, however they will not be recreated. All rows are created initially and used for binding on the client. To achieve the desired functionality you could try using the OnRowDataBound which is fired every time when the row is bound to data. Please give it try and let me know if it helps you. Looking forward for your reply.

Kind regards,
Radoslav
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
Accepted
David
Top achievements
Rank 2
answered on 20 Jun 2012, 10:09 AM
Thanks Radoslav :-)

I had figured it out :-) for anyone else experiencing this issue here is the final function

         function RowDatabound(sender, args) {
                var cid=args.get_dataItem().ContactID;
                var imgstr = "<img src='../smtImages/ico_Editsm.png' style='cursor:pointer' class='hightlighttracklist' onclick='initialiseEdit(" + cid + ")' />"
                var removeimgstr = "<img src='../smtImages/ico_Removesm.png' style='cursor:pointer' class='hightlighttracklist' onclick='initialiseRemove(" + cid + ")' />"

               var editLabel = args.get_item().get_cell("Tools").getElementsByTagName('span')[0];
               editLabel.innerHTML = imgstr;

               var removeLabel = args.get_item().get_cell("Tools").getElementsByTagName('span')[1];
               removeLabel.innerHTML = removeimgstr;
            }
Tags
Grid
Asked by
David
Top achievements
Rank 2
Answers by
Radoslav
Telerik team
David
Top achievements
Rank 2
Share this question
or