0

I am using following for jqgrid, it is working perfectly in jqgrid, but it is not displaying in mozilla 33.0 what is showing in chrome.

<script type="text/javascript" src="js/viewTestReq.js"></script>   
<script type="text/javascript" src="../js/popup/popup.js"></script>
<script type="text/javascript"
        src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript"
        src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>
<script type="text/javascript"
        src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.6.0/plugins/ui.multiselect-fixed.js"></script>
<script type="text/javascript"
        src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.6.0/js/i18n/grid.locale-en.js"></script>       
<script type="text/javascript"
        src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.6.0/js/jquery.jqGrid.src-columnChooser.js"></script>
<script type="text/javascript"
        src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.6.0/plugins/jQuery.jqGrid.setColWidth.js"></script>

<link rel="stylesheet" type="text/css"
      href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/redmond/jquery-ui.css">
<link rel="stylesheet" type="text/css"
      href="http://cdnjs.cloudflare.com/ajax/libs/jqgrid/4.6.0/css/ui.jqgrid.css">
<link rel="stylesheet" type="text/css" 
      href="http://cdnjs.cloudflare.com/ajax/libs/jqgrid/4.6.0/plugins/ui.multiselect.css">

and the JavaScript code

$("#list1").on("jqGridSortCol", function (e, sortName, iCol, sortOrder) {
    alert("sortName=" + sortName + "\niCol=" + iCol + "\nsortOrder=" + sortOrder);
     //$("#list1").trigger("reloadGrid");

    var myorder=sortOrder;
    if (sortName === "idreleaseRequest") {
        alert(sortOrder);
        var ord=sortOrder;
        alert(ord);

    }
});

$("#list1").jqGrid("GridUnload")
$("#list1").jqGrid({ url:"./controllers/apGetTestData.php?testanzres=1&testsuite="+testsuite+"&testcase="+testcase+"&ch="+ch+"&fromdate="+fromdate+"&todate="+todate+"&mmss="+mmss, datatype: 'xml', mtype: 'GET', height: 'auto',
    colNames:[ 'RRID', 'Release Tag','Completed Date','Result','Firm Ware','DUT','Summary','Remarks'],
    colModel:[
        {name:'idreleaseRequest', index:'idreleaseRequest', width:80, sorttype: 'int'},
        {name:'releaseRequestTag', index:'releaseRequestTag'},
        {name:'DateInfo', index:'Date Info'},
        {name:'Result', index:'Result', sortable:false},
        {name:'FirmWare', index:'FirmWare', sortable:false},
        {name:'DUT', index:'DUT', sortable:false},
        {name:'Summary', index:'Summary', sortable:false, align:'left'},
        {name:'Remarks', index:'Total Suites', sortable:false}],
    pager: $('#pager1'),
    rowNum:6,
    rowList:[6,12,18,24],
    sortname: 'idreleaseRequest',
    sortorder: "DESC",
    caption:"Test Results : "+ globalData,      
    height: 'auto',
    viewrecords: true,
    gridview: true,
    caption: "test",
    rownumbers:true,
    shrinkToFit:false,
    hidedlg: true
});
$('#list1').jqGrid("setLabel", "rn", "SNo");

$("#list1").on("jqGridAfterLoadComplete jqGridRemapColumns", function () {
    var $this = $(this),
        $cells = $this.find(">tbody>tr>td"),
        $colHeaders = $this.closest(".ui-jqgrid-view").find(">.ui-jqgrid-hdiv>.ui-jqgrid-hbox>.ui-jqgrid-htable>thead>.ui-jqgrid-labels>.ui-th-column>div"),
        colModel = $this.jqGrid("getGridParam", "colModel"),
        iCol,
        iRow,
        rows,
        row,
        n = $.isArray(colModel) ? colModel.length : 0,
        cm,
        colWidth,
        idColHeadPrexif = "jqgh_" + this.id + "_";
    $cells.wrapInner("<span class='mywrapping'></span>");
    $colHeaders.wrapInner("<span class='mywrapping'></span>");

    for (iCol = 0; iCol < n; iCol++) {
        cm = colModel[iCol];
        colWidth = $("#" + idColHeadPrexif + $.jgrid.jqID(cm.name) + ">.mywrapping").outerWidth() + 25; // 25px for sorting icons
        for (iRow = 0, rows = this.rows; iRow < rows.length; iRow++) {
            row = rows[iRow];
            if ($(row).hasClass("jqgrow")) {
                colWidth = Math.max(colWidth, $(row.cells[iCol]).find(".mywrapping").outerWidth());
            }
        }
        $this.jqGrid("setColWidth", iCol, colWidth);
    }
});

This is the entire code i am using for jqgrid, it is working perfectly in chrome, and it is displaying correctly in chrome that what i am expecting to be, but in Mozilla 33.0 it is not showing correctly, what is showing in chrome. Please anyone help me on this, in advance thanks.

function  ShowHideColumn () {
                $.extend(true, $.ui.multiselect, {
                locale: {
                    addAll: 'Make all visible',
                    removeAll: 'Hide All',
                    itemsCount: 'Avlialble Columns'
                }
            });
            $.extend(true, $.jgrid.col, {
                width: 450,
                modal: true,
                msel_opts: {dividerLocation: 0.5},
                dialog_opts: {
                    minWidth: 470,
                    show: 'blind',
                    hide: 'explode'
                }
            });
          $("#list1").jqGrid("setColProp", "rn", {hidedlg: false});
         $('#list1').jqGrid('columnChooser',
         {

            done: function(perm) {
               if (perm) { self.jqGrid("remapColumns", perm, true); }       

        }
         });


}
Sravya
  • 27
  • 11
  • Do you tested the code with *beta* version of Mozilla Firefox 33? The current release version of Firefox is 32.0.2. You wrote "it is not showing correctly" in Mozilla 33. What exactly incorrect is? Do you can reproduce the problem with [the original demo](http://www.ok-soft-gmbh.com/jqGrid/ChangeColumnWidth.htm) from [the answer](http://stackoverflow.com/a/20030652/315935)? Your demo still use `name` with spaces `name:'Firm Ware'` which is not recommended. – Oleg Sep 22 '14 at 05:10
  • this is the link for image what is displaying in chrome [link](http://s21.postimg.org/kec55xsmv/chromemain.jpg)Chrome, this is the link for image what is dislpaying in mozilla [link](http://s24.postimg.org/63ix0eqdh/mozillamain.jpg)Mozilla – Sravya Sep 22 '14 at 05:12
  • Hi Oleg, very happy for your reply, i posted the two images that how they are looking in chrome and Mozilla. – Sravya Sep 22 '14 at 05:15
  • Could you answer the questions from my previous comment? Where is your demo which can be used to *reproduce* the problem? What is the test case? Images can't be debugged... – Oleg Sep 22 '14 at 05:17
  • I tested in beta version also, but i am getting the same problem – Sravya Sep 22 '14 at 05:18
  • Could you answer the questions from my previous comment? **Which browser use used for the tests?** I don't know "Mozilla 33.0". I know Mozilla Firefox which release versions is 32.0.2. **Can you reproduce the same problem in [the demo]?** **What did you to reproduce the problem in your demo?** (the problem exist after initial loading of data or after sorting later or after column reordering/hiding by `columnChooser` or ...) The exact test case and the demo online to reproduce the problem is required. – Oleg Sep 22 '14 at 05:31
  • http://jsfiddle.net/xdaf5ggh/ this is the demo with My code, but i am getting problem with my data, i am getting that problem at initial loading, [Mozilla](http://s22.postimg.org/fety0ci35/aboutmoz.jpg) version image link – Sravya Sep 22 '14 at 05:40
  • Look at the official version of Mozilla: [here](https://www.mozilla.org/en-US/firefox/new/). One can download "Firefox Setup Stub 32.0.2.exe". [What's new](https://www.mozilla.org/en-US/firefox/32.0.2/releasenotes/) shows release notes of Version 32.0.2 published September 18, 2014. The jsfiddle demo http://jsfiddle.net/xdaf5ggh/ works without any problem on my Mozilla Firefox 32.0.2 (under Windows 8.1). – Oleg Sep 22 '14 at 05:53
  • I am unable to find the mistake i am using the same css files but they are not working in Mozilla, and i updated the Mozilla version, still it's not working.I am using window 7, whether problem is in sending request as url or what? – Sravya Sep 22 '14 at 07:17
  • By the way you use wrong `index` values in your demo http://jsfiddle.net/xdaf5ggh/. You have to remove `index:'id'`, `ndex:'invdate'` and `index:'name'` which breaks sorting of the grid. Just remove all `index` property from the demo and searching will work correctly. – Oleg Sep 22 '14 at 07:22
  • I wrote you previously that you should not use `name` values in `colModel` with spaces. You continue to use `name:'Firm Ware'`. You can use `jsonmap: "Firm Ware", name:"FirmWare"` (name without spaces). Usage of `index` other as `name` is also strictly not recommended: see `name:'Remarks', index:'Total Suites'`. I don't recommend you to use retro version of jQuery (1.7.1) with the current version of jQuery UI (1.11.1). If the problem will exist in *final* (release) version of Firefox 33 I will test it. – Oleg Sep 22 '14 at 07:29
  • Ok, i will make that changes, could you tell me that what version should i use for jQuery Ui(1.11.1),http://jsfiddle.net/xdaf5ggh/1/ – Sravya Sep 22 '14 at 08:01

1 Answers1

1

First of all: you use wrong HTML markup in your demo:

<table id="list_records"><div id="perpage"></div></table>

should be fixed to

<table id="list_records"></table><div id="perpage"></div>

Seconds you permanently use index values different as name value ({name:'FirmWare',index:'name'} for example). I strictly recommend you to remove all index properties from colModel. Usage of index values which values are not the same as name value of the grid break sorting in the column.

Third: Even after installing Mozilla Firefox 33.0 beta 5 on my computer (Windows 7) I can't reproduce your problem: the width of all columns seems be correct after the loading. If I sort by the last column in Asc or Desc direction I get correct width value for all columns too.

UPDATED: It seems to me that the code which implement setting of width of columns based on the max column contain should be fixed by adding if (cm.hidden) { continue; } after the line cm = colModel[iCol];:

$("#list1").on("jqGridAfterLoadComplete jqGridRemapColumns", function () {
    var $this = $(this),
        $cells = $this.find(">tbody>tr>td"),
        $colHeaders = $this.closest(".ui-jqgrid-view").find(">.ui-jqgrid-hdiv>.ui-jqgrid-hbox>.ui-jqgrid-htable>thead>.ui-jqgrid-labels>.ui-th-column>div"),
        colModel = $this.jqGrid("getGridParam", "colModel"),
        iCol,
        iRow,
        rows,
        row,
        n = $.isArray(colModel) ? colModel.length : 0,
        cm,
        colWidth,
        idColHeadPrexif = "jqgh_" + this.id + "_";
    $cells.wrapInner("<span class='mywrapping'></span>");
    $colHeaders.wrapInner("<span class='mywrapping'></span>");

    for (iCol = 0; iCol < n; iCol++) {
        cm = colModel[iCol];
        if (cm.hidden) {
            continue;
        }
        colWidth = $("#" + idColHeadPrexif + $.jgrid.jqID(cm.name) + ">.mywrapping").outerWidth() + 25; // 25px for sorting icons
        for (iRow = 0, rows = this.rows; iRow < rows.length; iRow++) {
            row = rows[iRow];
            if ($(row).hasClass("jqgrow")) {
                colWidth = Math.max(colWidth, $(row.cells[iCol]).find(".mywrapping").outerWidth());
            }
        }
        $this.jqGrid("setColWidth", iCol, colWidth);
    }
});

see the demo.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Hi Oleg, I solved my problem, and i am getting another issue i.e., after using column chooser, col widths are not working after choosing columns, i am writing seperate function for column chooser, i am adding that code above please see and help me. – Sravya Sep 22 '14 at 10:44
  • @Sravya: See **UPDATED** part of my code. Moreover I recommend you to look at the code of [the demo](http://www.ok-soft-gmbh.com/jqGrid/WorkingColumnChooser_.htm) which uses fixed version of `columnChooser` which you find [here](http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.6.0/plugins/jQuery.jqGrid.columnChooser.js) or [here](https://github.com/OlegKi/jqGrid-plugins/blob/master/jQuery.jqGrid.columnChooser.js). – Oleg Sep 22 '14 at 12:22
  • Hi @Oleg,i don't know whether to ask here or not, but i am asking, – Sravya Sep 23 '14 at 06:56
  • Hi @Oleg,i don't know whether to ask here or not, but i am asking, how to get sort order value outside of the jqgrid function, like $("#list1").on("jqGridSortCol", function (e, sortName, iCol, sortOrder) { alert("sortName=" + sortName + "\niCol=" + iCol + "\nsortOrder=" + sortOrder); //$("#list1").trigger("reloadGrid"); var myorder=sortOrder; if (sortName === "idreleaseRequest") { alert(sortOrder); var ord=sortOrder; alert(ord); } }); , i want to use (myorder) variable oustide of the function, if you know please tell me or else it's ok – Sravya Sep 23 '14 at 07:05
  • @Sravya: I'm not sure that I understand what you need. The event handler `jqGridSortCol` will be called *during* processing of click on column header. It allows to stop processing for example. If you need just know **the current sorting column and direction** of the grid you can just get `sortname` and `sortorder` parameters of the grid. For example `var sortName = $("#list_records").jqGrid("getGridParam", "sortname");` – Oleg Sep 23 '14 at 08:04