jQuery UI Widgets Forums Grid How to create new column after init of grid?

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

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

  • Zabelsky
    Participant

    Hello.
    I need your help.
    How to create new column at grid?1
    My code:

    $scope.loadGrid = function() {
                $scope.settings = getGridDispositionSettings();
                $scope.settings.source = new $.jqx.dataAdapter({ localdata: [] });
                var s = $scope.settings.source._source.localdata;
    
                $scope.settings.rowclick = function(event) {
                    $scope.selectedRow = event.args.row.bounddata;
                    $scope.selectedRowIndex = event.args.rowindex;
                }
    
                $scope.settings.source = new $.jqx.dataAdapter({ localdata: s });
                $scope.settings.editable = true;
                $scope.settings.groupable = false;
                $scope.settings.editmode = 'click';
    
                $scope.settings.columns = [
                    { text: "Напр", datafield: "_direction", width: 25, filtertype: 'checkedlist', resizable: false, cellsrenderer: asColumnRender, editable: false, type: "string", pinned: true, rendered: tooltiprenderer },
                    { text: "Рег.Номер", datafield: "_RegistrationNumbers", width: 90, resizable: false, cellsrenderer: asColumnRender, editable: false, type: "string", pinned: true, rendered: tooltiprenderer },
                    { text: "Караван", datafield: "_caravansForTractor", width: 90, type: "string", filtertype: 'checkedlist', cellsrenderer: caravanRender, editable: false, rendered: tooltiprenderer },
                    { text: "Блок", datafield: "_blocksForTractor", width: 80, type: "string", filtertype: 'checkedlist', cellsrenderer: blockRender, editable: false, rendered: tooltiprenderer },
                    { text: "Комм. инженера", datafield: "EngineerComment", cellsrenderer: asColumnRender, cellendedit: rowEditEngineerComment, width: 100, type: "string", rendered: tooltiprenderer }
                ];
                $scope.settings.columngroups = [
                    { text: 'Календарь', align: 'center', name: 'Calendar' }
                ];
    
                if (typeof $scope.calendarStart == 'undefined' || $scope.calendarStart !== new Date() && !$scope.calendarFlag) {
                    $scope.changeCalendarForGrid();
                }
                var firstDate = $scope.calendarStart;
                var secondDate = $scope.calendarEnd;
                var diffDays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime()) / (oneDay)));
                $scope.datafields = [];
                for (var k = 0; k <= diffDays; k++) {
                    var date = new Date();
                    date = firstDate.addDays(k);
                    var day = date.getDate();
                    var month = date.getMonth() + 1;
                    var datafield = '_Date_' + month + '_' + day;
                    $scope.settings.columns.push({ text: day + '-' + getDayOfWeek(date.getDay()), datafield: datafield, columnsreorder: false, width: 50, draggable: false, type: "string", columngroup: 'Calendar', cellsrenderer: calendarRender });
                    $scope.datafields.push(datafield);
                }
    }
    

    In current time I have columngroup ‘Calendar’ with next column “day + ‘-‘ + getDayOfWeek(date.getDay())”
    but in one moment i need to change this period on the other
    How to correctly add new columns to columngroup and to remove unnecessary from columngroup ?
    Thx for attention!

    With best regards,
    Alexey Zabelsky

    • This topic was modified 6 years, 7 months ago by  Zabelsky.

    Hristo
    Participant

    Hello Alexey Zabelsky,

    You could change initial object for the columngroups with a new one.
    Please, take a look at this topic, it demonstrates that approach:
    https://www.jqwidgets.com/community/topic/jqxgrid-columngroups-coumns-text-change-dynamcially/
    On the other side, you could change for each one particular column its ‘collumngroup’ by setcolumnproperty method of the Grid.

    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.