<table id="{{grid_name}}"></table><div id="{{grid_pager}}"></div>

<script type="text/javascript">

jQuery(window).load(function() {

		APL.Grid.obj = jQuery("#{{grid_name}}").jqGrid({

		pagerpos:"right",
		recordpos:"left",
		datatype:"{{datatype}}",
		url:"{{url}}",
		mtype:"{{mtype}}",
		colNames:[
		{%for column in columns%}
			{%if column.title is defined%}
			    '{{column.title}}',
			    {%else%}
				'{{column.name}}',
			{%endif%}
		{%endfor%}],
		colModel:   [
		{%for column in columns%}
			{
			    name:'{{column.name}}'
			{%if column.index is defined%}
			    ,index: '{{column.index}}'
			{%endif%}
			{%if column.nospan is defined%}
			    ,formatter:function(e){e = e>''?e:'';return '<span>'+e+'</span>';}
			{%endif%}    
			{%if column.width is defined%}
			    ,width:{{column.width}}
			{%endif%}  
			{%if column.align is defined%}
			    ,align:'{{column.align}}'
			{%endif%} 
			{%if column.search == false%}
			    ,search: false
			{%endif%}  
			{%if column.stype is defined and column.stype == 'select' and column.editoptions is defined%}
			    ,stype:'select', editoptions:{value:"{{column.editoptions}}"}
			{%endif%}
			{%if column.sortable == false%}
			    ,sortable: false
			{%endif%}  
			{%if column.hidden == true%}
			    ,hidden:true
			{%endif%}   
			{%if column.key == true%}
			    ,key: true
			{%endif%}  			    
			},
		{%endfor%}
		],
		rowNum:     {{rownum}},
		rowList:    [{{rowlist}}],
		pager:      "#{{grid_pager}}",
		sortorder:  "{{sortorder}}",
		sortname:   "{{sortname}}",
		shrinkToFit:true,
		autowidth:true,
		scrollOffset:25,
		multiboxonly:true,
		hoverrows:false,
		forceFit:false,
//		cellLayout:7,
			

	        {{caption}}

		viewrecords: {{viewrecords| json_encode}},

		hiddengrid:	{{hidden|json_encode}},
		
		width:{{width}},
                height:{{height}},
		loadui:		"{{loadui}}",
		loadtext:	"{{loadtext}}",
		multiselect: {{multiselect|json_encode}},
		postData: {
		    test:1
		{%for key,item in postData%}
			,{{key}}:'{{item}}'
		{%endfor%}    
		},

		recordpos: 'right',
		pagerpos: 'center',

		buttons:['reload','filter'],

		{{conf.footerSumm}}

{%if onclick_href == true%}

ondblClickRow:function(rowid){
    location.href = '{{url_form}}' + '?id='  + rowid
	}

{%endif%}
		

		}).jqGrid('filterToolbar',{
			//searchOperators:true
		});

		APL.Grid.obj[0].toggleToolbar();

		{%if adaptivesize == true%}

		APL.Grid.adaptiveSize();
		jQuery(window).smartresize(function(){
			APL.Grid.adaptiveSize();
		});

		{%endif%}

		APL.Grid.create_buttons(['reload','search']);

	});

</script>