Skip to content

Instantly share code, notes, and snippets.

@tucaz
Created November 1, 2011 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tucaz/1330999 to your computer and use it in GitHub Desktop.
Save tucaz/1330999 to your computer and use it in GitHub Desktop.
jqGridWrapper
var myNamespace = myNamespace || {};
myNamespace.jqGridWrapper = function (gridId, pagerId, gridUrl, gridConfig) {
var grid = $(gridId).jqGrid({
url: gridUrl,
datatype: "json",
colNames: gridConfig.colNames,
colModel: gridConfig.colModel,
rowNum: 10,
rowList: [10, 20, 30],
pager: pagerId,
sortname: gridConfig.sortName,
viewrecords: true,
sortorder: "asc",
caption: gridConfig.caption,
height: '100%',
width: '700px'
});
return grid;
}
var myConfiguredGrid = new myNamespace.jqGridWrapper(
'#EventsGrid',
'#EventsPager',
'../Event/GetAllEvents/',
{
colNames: ['Código', 'Nome do Evento', 'Cidade', 'Data de Início'],
colModel: [
{ name: 'EventId', index: 'EventId', width: 50, search : true, stype: 'text', searchoptions: { sopt: ['eq', 'ne'] } },
{ name: 'Name', index: 'Name', width: 250, search: true, stype: 'text', searchoptions: { sopt: ['eq', 'ne', 'bw', 'bn', 'ew', 'en', 'cn', 'nc']} },
{ name: 'City', index: 'City', width: 150, search: true, stype: 'text', searchoptions: { sopt: ['eq', 'ne', 'bw', 'bn', 'ew', 'en', 'cn', 'nc']} },
{ name: 'StartDate', index: 'StartDate', width: 80, search: false}],
sortname: 'EventId',
caption: "Eventos"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment