Backbone.js 如何用木偶实现jqGrid?
我试图在我的木偶应用程序中渲染jqGrid,一切正常,直到我找不到渲染寻呼机的方法。 我使用的是固定模板的把手,代码如下:Backbone.js 如何用木偶实现jqGrid?,backbone.js,jqgrid,marionette,Backbone.js,Jqgrid,Marionette,我试图在我的木偶应用程序中渲染jqGrid,一切正常,直到我找不到渲染寻呼机的方法。 我使用的是固定模板的把手,代码如下: hb template: <script id='llantas_grid_tmpl' type='text/x-handlebars-template'> <table id='llantas_catalog_list'></table> <div id="llantas_catalog_p
hb template:
<script id='llantas_grid_tmpl' type='text/x-handlebars-template'>
<table id='llantas_catalog_list'></table>
<div id="llantas_catalog_pager">pager</div>
</script>
layout...
ui: {
table: '#llantas_catalog_list',
pager: '#llantas_catalog_pager'
},
onRender: function(){
var table = this.ui.table,
pager = this.ui.pager;
table
.jqGrid({
url: '/llantas',
datatype: "json",
colNames:['Id','Orden De Compra', 'Marca', 'Medida', 'Modelo'],
colModel:[
{name:'id',index:'id', width:55},
{name:'ordencompra',index:'ordencompra', width:90},
{name:'marca',index:'marca', width:90},
{name:'medida',index:'medida', width:90},
{name:'modelo',index:'modelo', width:90}
],
rowNum:10,
rowList:[10,20,30],
pager: '#llantas_catalog_pager',
width:1060,
height:375,
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption:"<h3>Catalogo llantas<h3>"
});
table
.jqGrid('navGrid','#llantas_catalog_pager',{edit:false,add:false,del:false});
}
编辑:仅当您知道主干木偶和JQGRID时,请回答。总之,不
要确保它是字符串
if(!$t.grid || typeof elem !== 'string') {return;}
您需要修改jqGrid源代码。我找到了使其工作的方法: 一旦子视图(我试图使用jqGrid渲染的视图)被渲染并显示在主视图的区域中,我只需搜索模板表选择器并在jqGrid pager选项中传递页面id 主布局
onRender: function(){
// llantasGridView is the view holding only the template without the jqGrid (I erased everything)
var llantasGridView = new LlantasGrid.View();
// table_container is the region that will hold the llantasGridView template
this.table_container.show( llantasGridView );
// once is rendered I search for the table
var table = llantasGridView.$el.find('#llantas_catalog_list');
// here I pass the jqGrid
table
.jqGrid({
url: G.API + '/llantas',
datatype: "json",
colNames:['Id','PO'...
pager: '#llantas_catalog_pager', // pager for grid is now being displayed
...
pager
的值是什么?它是模板中的一个jQuery对象。实际上它允许传递一个我刚刚读过文档的对象:“有效调用可以是(使用我们的示例)“pager”,“pager”,“jQuery(“#pager”)。我建议使用第二个。”在呈现jqgrid时,您是在Itemview还是collection视图中呈现它,我认为这两个都不合适,我应该使用扩展常规主干视图的视图吗?
onRender: function(){
// llantasGridView is the view holding only the template without the jqGrid (I erased everything)
var llantasGridView = new LlantasGrid.View();
// table_container is the region that will hold the llantasGridView template
this.table_container.show( llantasGridView );
// once is rendered I search for the table
var table = llantasGridView.$el.find('#llantas_catalog_list');
// here I pass the jqGrid
table
.jqGrid({
url: G.API + '/llantas',
datatype: "json",
colNames:['Id','PO'...
pager: '#llantas_catalog_pager', // pager for grid is now being displayed
...