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

client RowDataBound problem

1 Answer 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 17 Feb 2015, 08:21 AM
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>





1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 19 Feb 2015, 02:20 PM
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.

 
Tags
Grid
Asked by
Christian
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or