jqGrid - extending for consistency

I would like to use jqGrid for a great many grids that have only a small set of application-specific column types, and I would like to create a way to enforce consistency. For example, I want all my columns that show the compliance status of a row to have a certain format, be aligned a certain way, have specific search options, etc. So instead of having a colmodel entry like this:

{ name: 'ABC', width: 80, align: 'center', stype: "select", searchoptions: { value: "1:Compliant;0:Not Compliant"} }

I would like to have one like this:

{ name: 'ABC', width: 80, mytype: compliancestatus }

where compliancestatus is a function I would write.

Is this kind of thing possible - without modifying the jqGrid source code? If so, can someone point me to an example of this type of extension?

-------------Problems Reply------------

Since jqGrid 3.8.2 are column templates supported.

You can just define for example

var compliancestatus = {
width: 80,
align: 'center',
stype: "select",
searchoptions: { value: "1:Compliant;0:Not Compliant" }
};

somewhere in the scope of visibility and then just use in colModel

{ name: 'ABC', template: compliancestatus }

In the template you can include any parameters. If the column definition has the same property but with the same value like

{ name: 'ABC', width: 100, template: compliancestatus }

the value from the colModel (width: 100 in the case) will be used.

I suggested the feature some time before and I use it intensively myself. For example I have many grids having many columns with checkboxes. I use the following template in the case:

mySettings.templateCheckbox = {
formatter: 'checkbox', align: 'center', width: 20,
edittype: 'checkbox', editoptions: { value: "1:0" },
stype: "select", searchoptions: { sopt: ['eq', 'ne'], value: ":Any;1:Yes;0:No" }
};

In the same way I defined many other templates which reduce the code of grids and improve managing of the common grid style.

If you want to change some common default settings for all columns you can use cmTemplate parameter of jqGrid. For example

cmTemplate: { align: 'center' }

You can use it as additional parameter of jqGrid or set it like any other default parameter with respect of

$.extend($.jgrid.defaults, {
cmTemplate: { align: 'center' }
});

Read more about the column templates here.

Category:jqgrid Views:0 Time:2011-09-17
Tags: jqgrid

Related post

  • jqGrid extend configurations from other jqGrid 2011-09-22

    I will have many jqGrid tables at my application. However it is not easy to write every configuration of it again and again (i.e. viewrecords: true, sortorder: "desc", multiselect: true, multiboxonly: true, ) How can I instruct a basic grid and exten

  • jqgrid - extending addRowData 2012-02-11

    Thanks to Oleg, I have the solution to adding a row anywhere in the grid. BUT I want this functionality NOT when there is an "Add" link in the inlineNav BUT when I click on the jqgrid caption - MY JQGRID Is it possible? HTML <table id="myjqgrid"

  • Adding a function to jqGrid jQuery plugin 2011-06-17

    I am trying to add a function named rows to the jqGrid jQuery plugin, but I can't determine the syntax. Here are my non-working versions. (function($) { $.fn.jgrid.rows = function(data) { // do something }; }); (function($) { $.fn.rows = function(dat

  • Adding a function to jqGrid to add local JSON 2011-06-17

    I"m trying to create an additional function for jqGrid to simplify adding JSON data to a grid that uses local data. The following attempt works except for one line, which causes it to fail. $.fn.myrows = function(data) { $(this).clearGridData(); $(th

  • CodeIgniter jqGrid undefined 2011-11-09

    I have a problem using CodeIgniter and jqGrid. The grid has the right design but does not load the data into the grid. The message displayed is "undefined". <head> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/dark-h

  • jquery subgrid with json 2009-08-16

    I am working with jqgrid. i have need to implement subgrid of grid. my code is as follows: <div class="ww90p"> <!-- class="sheet"--> <div class="" > <table id="setcols" class="scroll"> </table> <div id="psetcols" clas

  • How to handle variation in service method inputs 2010-09-20

    I have a client application that should be able to handle the following: 1) Request sql statments that are to to be executed against the client. 2) Request Service Packs or Hoxfixes that will be executed against to the client. 3) There may be more ty

  • Jiffies Counter Over Flow case + Linux 2011-01-17

    Jiffies counter returns an unsigned integer of size four bytes. when the counter reaches maximum value then it restarts from 0 again. I'll subtract the latest value with the old value to get the duration. So how should i consider for a case such that

  • iPhone to RS-232 via Bluetooth 2011-09-14

    I'm looking to connect my iPhone to an RS-232 serial device via Bluetooth. Has anyone implemented this successfully and can offer advice on hardware to use? It's kind of tricky because of the need for the Apple Authentication Processor with the devic

  • Generate output along with recursive descent parser 2011-10-20

    Writing simple parsers are trivial and I have implemented several over the years. In college, we also had to write one. But we never had to generate meaningful output using this method; we never learned how to create a back end. If I have a working r

  • missing hard disk partitions.. 2014-10-09

    unable to see my other disk partitions of my hard disk,except the c drive.. i've checked through disk management... the missing drives do not have any letters and have been converted to logical drive...please suggest some measures --------------Solut

  • Memcache - How extend expiration of value with keeping consistency of value? 2010-06-03

    See this simple piece of code in PHP: //Documentation: //memcache_set ( string $key , mixed $var [, int $flag [, int $expire ]] ) //memcache_increment ( string $key [, int $value = 1 ] ) //part 1 memcache_set ( 'id' , 1 , 0 , 60 ); //part 2 $id = mem

  • Extending the File class to provide user a consistent way on filesystems over network channels transparently 2010-09-06

    I'm implementing a Java-based system which needs accessing both the native and networked filesystems. Using the Java File class is easy and straight forward in the native case, and I'd like to keep this consistency to user even the filesystem is conn

  • extended attributes are not consistent 2013-04-24

    This is one of a handful of error messages I see every time I try to use any windows application ever since trying to upgrade my PC Tools Reg Mechanic to 2011. During the install something got hosed up and I had to manually shut the system down. I am

  • Is it appropriate to extend Control to provide consistently safe Invoke/BeginInvoke functionality? 2009-04-03

    In the course of my maintenance for an older application that badly violated the cross-thread update rules in winforms, I created the following extension method as a way to quickly fix illegal calls when I've discovered them: /// <summary> ///

  • jqGrid trigger "Loading-" overlay 2010-04-24

    Does anyone know how to trigger the stock jqGrid "Loading..." overlay that gets displayed when the grid is loading? I know that I can use a jquery plugin without much effort but I'd like to be able to keep the look-n-feel of my application consistent

  • Bring selected rows to the top from the Jqgrid 2011-11-14

    I am using jqgrid in 'multiselect' mode and without pagination. When the user selects individual records by using mouse click, is there any way that I can bring those selected records to the top of the grid? Thanks in advance for your help. ---------

  • JQGrid: Resize Grid Width After Column Resized 2012-03-06

    I would like to resize the width of the grid after a column is resized (so the width of the grid will match the sum of the widths of the columns, including the new width of the resized column). This should prevent the horizontal scrollbar from appear

  • jqGrid Tree Node Structure for Task and Sub-Task 2014-11-24

    jqGrid script <script type="text/javascript"> var call_url = "<?php echo SOME_URL ?>"; jQuery("#grid").jqGrid({ url:call_url, datatype: "json", height: 'auto', treeGrid: true, treeGridModel: "adjacency", ExpandColumn: 'TASK_NAME', rowNum:

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.157 (s). 11 q(s)