jQuery UI Widgets Forums TreeGrid checkRow not working after first page in jqxTreeGrid

This topic contains 1 reply, has 2 voices, and was last updated by  Hristo 6 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • viveknuna
    Participant

    I have a jqxTreeGrid, I’m selecting some rows, it selects rows only on the first page. On other pages, it’s not selecting.

    `$scope.get_db_data_parent = function (rowdata) {

    if(rowdata == undefined){
    var url = ‘api/bdi_pf_data’;
    }
    else{
    var url = ‘api/bdi_pf_data_not_platform_id?platform_id=’ + rowdata.platform_id;
    }

    $http.get(url).success(function (data) {
    console.log(url, data.response);
    var view = 0;
    var ids = []
    if (rowdata !== null && rowdata !== undefined) {
    view = 1;
    ids = rowdata.parent_platfoms.split(“,”);
    }
    var table_contents = [];
    for (var i = 0; i < data.response.length; i++) {
    arr_list_parent.push(data.response[i])
    data.response[i][‘select’] = false;

    var a = data.response[i];
    table_contents.push({
    select: a[‘select’],
    platform_id: a[‘platform_id’], platform_name: a[‘platform_name’],
    platform_type: a[‘platform_type’], template_name: a[‘template_name’]
    })
    }

    console.log(table_contents);

    var source =
    {
    dataType: “json”,
    dataFields: [
    { name: ‘select’, type: ‘bool’ },
    { name: ‘platform_id’, type: ‘number’ },
    { name: ‘platform_name’, type: ‘string’ },
    { name: ‘platform_type’, type: ‘string’ },
    { name: ‘template_name’, type: ‘string’ }
    ],
    // hierarchy:
    // {
    // keyDataField: { name: ‘event_id’ },
    // parentDataField: { name: ‘event_parent_id’ }
    //
    // },
    // id: “platform_id”,
    localData: table_contents
    };
    console.log(source);
    //angular.copy(source, $scope.gridData);
    var dataAdapter = new $.jqx.dataAdapter(source);

    $(“#treeGridPlatform”).on(‘bindingComplete’, function (event) {
    // try {
    if (view == 1) {
    for (var i = 0; i < ids.length; i++) {
    for (var j = 0; j < table_contents.length; j++) {
    if (table_contents[j].platform_id.toString() == ids[i].toString()) {
    var t = table_contents[j].platform_id.toString();
    table_contents[j].select = true;
    }
    }
    }
    }
    //for (var i = 0; i < table_contents.length; i++) {
    //if (table_contents[i].select == true) {
    // var p = table_contents[i].platform_id;
    //$(‘#treeGridPlatform’).jqxTreeGrid(‘checkRow’, i);
    //if(i == )
    $timeout(function () {
    try {
    $(‘#treeGridPlatform’).jqxTreeGrid(‘checkRow’, 2);
    $(‘#treeGridPlatform’).jqxTreeGrid(‘checkRow’, 5);
    $(‘#treeGridPlatform’).jqxTreeGrid(‘checkRow’, 45);
    $(‘#treeGridPlatform’).jqxTreeGrid(‘checkRow’, 51);
    }
    catch (e) {
    }
    }, 5000)

    //$(‘#treeGridPlatform’).jqxTreeGrid(‘checkRow’, 38);
    //}
    //}
    // }
    // catch (e) {
    //
    // }
    });
    // create Tree Grid

    var editable = true;
    if ($scope.update == true && $scope.view == true) {
    editable = false;
    }

    $(“#treeGridPlatform”).jqxTreeGrid(
    {
    width: ‘100%’,
    source: dataAdapter,
    sortable: true,
    editable: true,
    pageable: true,
    pagerMode: ‘advanced’,
    checkboxes: true,
    theme: ‘arctic’,
    filterable: true,
    //filterMode: ‘simple’,
    incrementalSearch: true,

    //columnsResize: true,
    // ready: function()
    // {
    // $(“#treeGrid”).jqxTreeGrid(‘expandRow’, ‘2’);
    //
    // },
    editSettings: {
    editOnDoubleClick: false
    },
    columns: [
    // {
    // text: ‘Select’,
    // width: ‘10%’,
    // datafield: ‘select’,
    // columntype: ‘checkbox’,
    // type: ‘bool’,
    // pinned: true
    // },

    { text: ‘Platform ID’, dataField: ‘platform_id’, editable: false },
    { text: ‘Platform Name’, dataField: ‘platform_name’, cellsrenderer: cellsrendererCenter, editable: false },
    { text: ‘Platform Type’, dataField: ‘platform_type’, type: ‘string’, editable: false, cellsrenderer: cellsrendererCenter },
    { text: ‘Database Type’, dataField: ‘template_name’, type: ‘string’, editable: false, cellsrenderer: cellsrendererCenter }
    ],
    columnGroups: [
    { text: ‘Name’, name: ‘Name’ }
    ]
    });

    var user_clicked = true;
    $(“#treeGridPlatform”)
    .on(‘rowCheck’, function (event) {
    var args = event.args;
    var row = args.row;
    var platform_id = row.platform_id;

    // if (editable == false && user_clicked == true) {
    // user_clicked = false;
    // $(‘#treeGridPlatform’).jqxTreeGrid(‘uncheckRow’, platform_id);
    // return false;
    // }
    // else if (editable == true) {
    //
    // try {
    // if (row.parent == null) {
    // for (var index = 0; index < row.records.length; index++) {
    // $(‘#treeGridPlatform’).jqxTreeGrid(‘checkRow’, row.records[index].platform_id);
    // }
    // }
    // }
    // catch (e) {
    //
    // }
    // }
    user_clicked = true;
    selected_platform_id.push(platform_id);
    });

    $(“#treeGridPlatform”)
    .on(‘rowUncheck’, function (event) {
    var args = event.args;
    var row = args.row;
    var platform_id = row.platform_id;
    // if (editable == false && user_clicked == true) {
    // user_clicked = false;
    // $(‘#treeGridPlatform’).jqxTreeGrid(‘checkRow’, platform_id);
    // return false;
    // }
    // else if (editable == true) {
    //
    // try {
    // if (row.parent == null) {
    // for (var index = 0; index < row.records.length; index++) {
    // $(‘#treeGridPlatform’).jqxTreeGrid(‘uncheckRow’, row.records[index].platform_id);
    // }
    // }
    // }
    // catch (e) {
    //
    // }
    // }
    user_clicked = true;
    var i = selected_platform_id.indexOf(platform_id);
    if (i > -1) {
    selected_platform_id.splice(i, 1);
    }
    });

    $(‘#treeGridPlatform’).on(‘cellBeginEdit’,
    function (event) {
    var args = event.args;
    // row key
    var rowKey = args.key;
    // row’s data.
    var row = args.row;
    // column’s data field.
    var columnDataField = args.dataField;
    // column’s display field.
    var columnDisplayField = args.displayField;
    // cell’s value.
    var value = args.value;
    });
    }
    )
    .error(function (error) {
    console.log(url, error);
    });
    }`

    $scope.get_db_data_parent();

    <div id="treeGridPlatform" ng-if="(newPlatform == true || update == true)" ng-disabled="update && view">
                </div>

    Hristo
    Participant

    Hello viveknuna,

    I tested this example and it seems to work fine (the checkRow method):
    http://jsfiddle.net/jqwidgets/3rt8z/
    I would like to suggest you look at this tutorial:
    http://www.jqwidgets.com/jquery-widgets-documentation/documentation/angularjs/angularjs.htm?search=

    I would like to suggest you try to implement ready callback in the jqxTreeGrid and there you should use one of the two approaches of using methods
    Please, take a look at this example.

    ready: () => {
    	// The First Approach
    	$scope.treeGridSettings.apply('checkRow', 2);
    	// The Second Approach
    	$scope.treeGridSettings.jqxTreeGrid('checkRow', 5);
    },

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.