Hi,
thank you for your answer. I tried your code but it did not work for me. I have a treegrid with a checkbox column built with the following template:
<script type='text/x-jsrender' id='checkColumnTemplate'> <input type='checkbox' class='rowCheckbox' id='chk' onclick='checkUnCheck(this, {{:#data['nodeID']}});' {{if #data['visible']=='1'}} CHECKED>{{/if}}</script>
Here is the javascript code I use:
function checkUnCheck(ctrl, curNodeId) {
var treegridObj = $('#treeGrid').data('ejTreeGrid');
PIKR.WServices.Tree.SetTreeVisibility(curNodeId, ctrl.checked, rootNodeId, true, function (res) {
if (res != null) {
var flatRecords = treegridObj.model.flatRecords;
$('#treeGrid').ejTreeGrid(
{
dataSource: JSON.parse(res)
});
expandGrid(flatRecords, curNodeId);
}
});
}
function expandGrid(flatRecords, curNodeId) {
var selectedIndex = -1;
var treegridObj = $('#treeGrid').data('ejTreeGrid');
for (var i = 0; i < treegridObj.model.flatRecords.length; i++) {
var nodeId = treegridObj.model.flatRecords[i].nodeID;
var foundNode = $.grep(flatRecords, function (e) { return e.nodeID == nodeId; })
if (foundNode.length >= 1) {
if (treegridObj.model.flatRecords[i].hasChildRecords)
treegridObj.model.flatRecords[i].expanded = foundNode[0].expanded;
if (foundNode[0].isSelected)
treegridObj.model.flatRecords[i].isSelected = foundNode[0].isSelected;
treegridObj.refreshRow(i);
}
// treegridObj.updateExpandStatus(treegridObj.model.flatRecords[i], true);
}
treegridObj.refreshContent();
treegridObj.renderRecords();
}
function treeGrid_RowSelected(args) {
var obj = $("#treeGrid").data("ejTreeGrid");
obj.updateScrollBar(args.recordIndex);
}
The row is selected and the function treeGrid_RowSelected is executed but the scroll is at the beginning of the grid. Can you help me?
Best regards.