tonytomov/jqGrid — pull request #631 by OlegKi (2014-08-29 18:32:26+00:00)
Title: Allow to define named templates

Hello Tony,

If one loads `colModel` from the server it's very practical to have properties which can be represented in JSON. If one want to use `dataIni` or other callbacks (for jQuery UI Datepicker, select2 or other controls) one can't load such column definition via JSON. jqGrid contains already practical feature in formatters. Formatters allow to extent `$.fn.fmatter` and assign **string name** to custom formatter and extend `$.unformat` to register the corresponding unformatter. In the way one can easy extend the list of predefined formatters.

jqGrid supports `template` property of `colModel` starting from version 3.8.2, but the value have to be an object. I suggest to make small modification of the code to allow to use for example `template: "number"`. To define `number` template one need just define `$.jgrid.cmTemplate.number` using

$.extend($.jgrid, {
cmTemplate: {
number: {
formatter: "number", align: "right", sorttype: "number", searchoptions: { sopt: ["eq", "ne", "lt", "le", "gt", "ge"] }
}
}
});

I think that such small change can makes long code which uses jqGrid more small and more easy to maintain.

[The demo](http://www.ok-soft-gmbh.com/jqGrid/templateAsString.htm) demonstrates the usage of jqGrid after applying of suggested pull request.

You can consider to define some standard templates for numbers, intergers and dates at the beginning of `grid.base.js`.

Best regards
Oleg