5

I have seen the following demo with frozen column and filter toolbar here: http://www.ok-soft-gmbh.com/jqGrid/FrozenColumns.htm

Now for the same example I want to implement toggle feature that was availbale in demo: http://www.ok-soft-gmbh.com/jqGrid/SimpleLocalGridWithSearchingToolbar1.htm

I tried it but it is not working.. can anybody create a demo that has both frozen column and toggle filter tool bar?


I tried to download the latest jqgrid code from github and tried to replicate the demo as follows( as u said the issue was fixed i thought no need of the frozendiv, fixGBoxHeight functions in the demo u have shown me previously i.e http://www.ok-soft-gmbh.com/jqGrid/FrozenColumnsAndFilterToggle.htm)

    $grid.jqGrid({
        datatype: 'local',
        data: mydata,
        colNames: [/*'Id', */'Client', 'Date', 'Amount', 'Tax', 'Total', 'Closed', 'Shipped via', 'Notes'],
        colModel: [
            //{name: 'id', index: 'id', width: 45, align: 'center', sorttype: 'int', frozen: true},
            {name: 'name', index: 'name', width: 70, editable: true, frozen: true},
            {name: 'invdate', index: 'invdate', width: 80, align: 'center', sorttype: 'date',
                formatter: 'date', formatoptions: {newformat: 'm/d/Y'}, datefmt: 'm/d/Y'},
            {name: 'amount', index: 'amount', width: 75, formatter: 'number', align: 'right', editable: true},
            {name: 'tax', index: 'tax', width: 50, formatter: 'number',
                formatoptions: {decimalSeparator: ".", thousandsSeparator: " ", decimalPlaces: 4, defaultValue: '0.0000'},
                align: 'right', editable: true, editoptions: {readonly: true}},
            {name: 'total', index: 'total', width: 60, formatter: 'number', align: 'right', editable: true},
            {name: 'closed', index: 'closed', width: 70, align: 'center', editable: true,
                formatter: 'checkbox', edittype: 'checkbox', editoptions: {value: 'Yes:No', defaultValue: 'Yes'}},
            {name: 'ship_via', index: 'ship_via', width: 100, align: 'center', formatter: 'select', editable: true,
                edittype: 'select', editoptions: {value: 'FE:FedEx;TN:TNT;IN:Intim', defaultValue: 'Intime'}},
            {name: 'note', index: 'note', width: 70, sortable: false, editable: true}
        ],
        rowNum: 10,
        rowList: [5, 10, 20],
        pager: '#pager',
        gridview: true,
        rownumbers: true,
        sortname: 'invdate',
        viewrecords: true,
        sortorder: 'desc',
        caption: 'Frozen columns with dynamic shown filter toolbar',
        height: '100%',
        shrinkToFit: false,
        width: 550,
        resizeStop: function () {
            /*resizeColumnHeader.call(this);
            fixPositionsOfFrozenDivs.call(this);
            fixGboxHeight.call(this);*/
        },
        loadComplete: function () {
            //fixPositionsOfFrozenDivs.call(this);
        }
    });
    $grid.jqGrid('navGrid', '#pager', {add: false, edit: false, del: false}, {}, {}, {},
        {multipleSearch: true, overlay: 0});
    $grid.jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch: 'cn'});
    $grid.jqGrid('navButtonAdd', '#pager', {
        caption: "Filter",
        title: "Toggle Searching Toolbar",
        buttonicon: 'ui-icon-pin-s',
        onClickButton: function () {
            this.toggleToolbar();
            /*if ($.isFunction(this.p._complete)) {
                if ($('.ui-search-toolbar', this.grid.hDiv).is(':visible')) {
                    $('.ui-search-toolbar', this.grid.fhDiv).show();
                } else {
                    $('.ui-search-toolbar', this.grid.fhDiv).hide();
                }
                this.p._complete.call(this);
                fixPositionsOfFrozenDivs.call(this);
            }*/
        }
    });
    $grid[0].toggleToolbar();
    /*$grid.jqGrid('gridResize', {
        minWidth: 450,
        stop: function () {
            fixPositionsOfFrozenDivs.call($grid[0]);
            fixGboxHeight.call($grid[0]);
        }
    });
    resizeColumnHeader.call($grid);*/
    $grid.jqGrid('setFrozenColumns');
    /*$grid.p._complete.call($grid);
    fixPositionsOfFrozenDivs.call($grid);*/
});

But still the code is not going to work and the filtertoolbar not working as it is in your previous demo(http://www.ok-soft-gmbh.com/jqGrid/FrozenColumnsAndFilterToggle.htm)

Tim Post
  • 33,371
  • 15
  • 110
  • 174
Rohini Kumar
  • 249
  • 1
  • 5
  • 15

1 Answers1

4

First of all I would recommend you to use the demo from the answer as the basis instead of the demo from the previous answer.

You are right. The current implementation of frozen columns has problem with dynamic showing or hiding of the searching toolbar. I interpret it as a bug in the toggleToolbar.

Till the bug is not fixed I suggest that you show or hide the toolbar in the frozen part of the grid manually. The demo shows how to implement this. The most important part of the code of the demo you find below:

$grid.jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch: 'cn'});
$grid.jqGrid('navButtonAdd', '#pager', {
    caption: "Filter",
    title: "Toggle Searching Toolbar",
    buttonicon: 'ui-icon-pin-s',
    onClickButton: function () {
        this.toggleToolbar();
        if ($.isFunction(this.p._complete)) {
            if ($('.ui-search-toolbar', this.grid.hDiv).is(':visible')) {
                $('.ui-search-toolbar', this.grid.fhDiv).show();
            } else {
                $('.ui-search-toolbar', this.grid.fhDiv).hide();
            }
            this.p._complete.call(this);
            fixPositionsOfFrozenDivs.call(this);
        }
    }
});
$grid[0].toggleToolbar();
Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thanks oleg.. Sorry for the delayed response. but this is what i am exactly looking for.. One doubt is, if i have multiple grids on the page, then is it possible to move the 3 functions i.e resizeColumnHeader, fixPositionsOfFrozenDivs, fixGboxHeight to a common block so that i can use them for all the grids.. – Rohini Kumar Jan 25 '12 at 04:50
  • @user109124: Yes you can of course. You can also fix [the bug](http://www.trirand.com/blog/?page_id=393/bugs/usage-of-toggletoolbar-with-frozen-columns/#p25779) which is already [fixed](https://github.com/tonytomov/jqGrid/commit/f802d0329f4d1740e57bd52cdf251858284a0e8b) in the main code of jqGrid. – Oleg Jan 25 '12 at 06:17
  • @Oleg how the same can be achieved as the grid loads , as I am supplying search = true in my colModel. – Vikas Apr 20 '17 at 12:41
  • @Vikas: I don't understand what you mean. First of all, which version of jqGrid you use (can use) and from which fork of jqGrid ([free jqGrid](https://github.com/free-jqgrid/jqGrid), commercial [Guriddo jqGrid JS](http://guriddo.net/?page_id=103334) or an old jqGrid in version <=4.7). I develop "free jqGrid" fork and the problem with frozen columns described in the question should not exist in the fork. – Oleg Apr 20 '17 at 12:45
  • version jqGrid 4.9.2 , freejqgrid, so when I am passing search = true in the object of the colmodel and if that column is frozen, search input text box does not appear. – Vikas Apr 20 '17 at 13:19
  • @Vikas: The current version of free jqGrid is 4.14.0. You should upgrade to it first of all. – Oleg Apr 20 '17 at 13:21
  • @Vikas: If one speak about some product one means **the latest** version or at least the previous one. Other retro versions are not supported. For example, if you use Google Chrome then you have to use the version 58 or 57. The version will be changed every 1.5-2 months. There are some exceptions by commercial products, but the most open source free products follow the rule: one should use the last version. – Oleg Apr 20 '17 at 13:26
  • @Oleg I will have to stick to older version of the jqgrid , as it need to work on the little older browser also – Vikas Apr 20 '17 at 13:39
  • @Vikas: Both 4.14.0 and 4.9.2 should work on the same web browsers. Which web browser and in which version exactly you mean? If you find some problem in *the last version* 4.14.0 I could try to fix it. If you want hold old version then you should don't use new features. By the way, I rewrote many parts of jqGrid to better support frozen columns and essentially improve it's performance. – Oleg Apr 20 '17 at 13:43