2

The jGrid supports the column templates. Which can be used as the default template for all columns. Some explanation is at Stopping columns resizable in jqgrid

An the sample code from there:

var myDateTemplate = {sorttype:'date', formatter:'date',
                      formatoptions: {newformat:'m/d/Y'}, datefmt: 'm/d/Y',
                      align:'center', width:80 }
$("list").jqGrid({
    colModel: [
        ...
        {name:'column1': template:myDateTemplate},
        {name:'column2': template:myDateTemplate, width:90},
        ...
    ]
    ...
});

Is it possible that we use this feature while we are using jquery grid tags sjg:grid and sjg:gridColumn ? How?

Community
  • 1
  • 1
Alireza Fattahi
  • 42,517
  • 14
  • 123
  • 173
  • Struts2 uses some JavaScript version of jqGrid, included directly. Which version of jqGrid you use now and from which fork ([free jqGrid](https://github.com/free-jqgrid/jqGrid), [Guriddo jqGrid JS](http://guriddo.net/?page_id=103334) or an old jqGrid in version <=4.7)? If you use old one than I think all will works exactly in the same way if you replace `jquery.jqgrid.min.js`, .... to new version. The problem is: the last versions of jqGrid supports **string** value for `template`. I think that it makes easy the usage of `sjg:gridColumn`. Do you have some demo which shows how you use jqGrid? – Oleg Feb 02 '16 at 16:58
  • You can find a live demo and code samples at http://struts.jgeppert.com/struts2-jquery-showcase/index.action Please select widgets and then grid. I have use it the same why which mentioned there. If you need more info please let me know. It uses jqGrid verison 4.6.0 You can find it at (http://struts.jgeppert.com/struts2-jquery-showcase/struts/js/plugins/jquery.jqGrid.js?s2j=3.7.1). Thanks! – Alireza Fattahi Feb 02 '16 at 17:06
  • I don't use Struts2 or Java myself, but the code from https://github.com/struts-community-plugins/struts2-jquery/tree/master/struts2-jquery-grid-plugin/src/main seems be the last one. It contains the JavaScript code of jqGrid and simple wrapper structures for every property. Like [here](https://github.com/struts-community-plugins/struts2-jquery/blob/master/struts2-jquery-grid-plugin/src/main/java/com/jgeppert/struts2/jquery/grid/components/GridColumn.java), ... – Oleg Feb 02 '16 at 17:24
  • [here](https://github.com/struts-community-plugins/struts2-jquery/blob/master/struts2-jquery-grid-plugin/src/main/java/com/jgeppert/struts2/jquery/grid/views/jsp/ui/GridColumnTag.java). [Here](https://github.com/struts-community-plugins/struts2-jquery/tree/master/struts2-jquery-grid-plugin/src/main/resources/template) are original jqGrid JavaScript files. It seems that you can replace the JavaScript files to [free jqGrid](https://github.com/free-jqgrid/jqGrid) files and make minimal changes of the code or wrapper classes to use new functionality. – Oleg Feb 02 '16 at 17:26

0 Answers0