client RowDataBound problem

2 posts, 0 answers
  1. Christian
    Christian avatar
    64 posts
    Member since:
    Apr 2008

    Posted 17 Feb 2015 Link to this post

    No matter how I try I always end up with the first item in args.get_item below, in my example below one of the images should be hidden on row 4, but instead it hides it on row 1 no matter what I try, the data_item seem to be correct, item or findelement does not and I´m guessing I´m finding the element to hide in the wrong manner, any tips?


    function RowDataBound(sender, args) {
    var di = args.get_dataItem();
    var item = args.get_item();
     
    var sortUp = item.findElement('btnSortUp')
    var sortDown = item.findElement('btnSortDown')
     //var sortUp = $(item).find("btnSortUp");
     //var sortDown = $(item).find("btnSortDown");
     
    var pos = di.abdp_pos_no;
     
     if (pos == 1) {
     $(sortDown).hide();
     }
     if (pos == 4) {
     $(sortUp).hide();
     }
    }


    <telerik:GridTemplateColumn HeaderText="Sort" UniqueName="sort" SortExpression="abdp_pos_no" DataField="ben">
                    <HeaderStyle HorizontalAlign="Right" />
                    <ItemStyle HorizontalAlign="Right" />
                    <ClientItemTemplate>
                        <img id="btnSortUp" src="images/copy.png" data-pos="#=abdp_pos_no #" data-way="-1" style="cursor:pointer;" onclick="reorder(this)"></img>
                        <img id="btnSortDown" src="images/copy.png" data-pos="#=abdp_pos_no #" data-way="+1" style="cursor:pointer;" onclick="reorder(this)"></img>
                    </ClientItemTemplate>
                </telerik:GridTemplateColumn>





  2. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 19 Feb 2015 Link to this post

    Hi,

    Please try modifying the code as demonstrated below and let us know how it goes.

    JavaScript:
    function RowDataBound(sender, args) {
                    var di = args.get_dataItem();
                    var item = args.get_item();
                    var pos = di.abdp_pos_no;
                    if (pos == 1) {
                        $(item.get_cell("sort")).find('#btnSortUp').hide();
                    }
                    if (pos == 4) {
     
                        $(item.get_cell("sort")).find('#btnSortDown').hide();
                    }
                }


    Regards,
    Angel Petrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top