OnRowCreated not raised on repaint

3 posts, 0 answers
  1. David
    David avatar
    10 posts
    Member since:
    Apr 2008

    Posted 14 Jun 2012 Link to this post

    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. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 20 Jun 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. David
    David avatar
    10 posts
    Member since:
    Apr 2008

    Posted 20 Jun 2012 Link to this post

    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;
                }
Back to Top