如何从json的“单元"显示所选参数. [英] How to display selected parameters from the 'cell' of the json .
问题描述
我没有找到'colModel'的name
参数的使用,因为我只想显示json的"cell"中的选定参数.在对新项目实施之前,我正在使用json对flexigrid进行某种测试.
我的脚本是这样的:
I am not finding the use of name
parameter of ''colModel'' because i only want to display selected parameters from the ''cell'' of the json. I am doing some sort of testing on flexigrid with json before implementing on my new project .
My script goes like this :
$(document).ready(new function(){
$("#fgrdProduct").flexigrid
(
{
url: 'registration/handlers/LoadUsers1.ashx',
dataType: 'json',
colModel : [
{ display: 'tameliTypeID', name: 'TameliTypeID', width: 20, sortable: true, align: 'left' },
{ display: 'tameliTypeName', name: 'TameliTypeName', width: 180, sortable: true, align: 'left' }
],
searchitems : [
{ display: 'TameliTypeID', name: 'TameliTypeID' },
{ display: 'TameliTypeName', name: 'TameliTypeName' }
],
sortname: "TameliTypeName",
sortorder: "asc",
usepager: true,
title: 'Tameli List',
useRp: true,
rp: 10,
showTableToggleBtn: true,
width: 805,
onSubmit: addFormData,
height: 200
}
);
我的代码以以下格式返回json:
My code returns the json in the format :
{"page":1,"total":9,"rows":[{"id":"0","cell":["{}","","Y","","","1","बिद्युतीय"]},{"id":"1","cell":["{}","","Y","","","2","अदालतको तामेलदारद्वारा"]},{"id":"2","cell":["{}","","Y","","","3","अन्य अदालतको माध्यमद्वारा"]},{"id":"3","cell":["{}","","Y","","","4","प्रहरीद्वारा"]},{"id":"4","cell":["{}","","Y","","","5","पत्रपत्रिका"]},{"id":"5","cell":["{}","","Y","","","6","हुलाक"]},{"id":"6","cell":["{}","","Y","","","7","स्थानीय निकाय"]},{"id":"7","cell":["{}","","Y","","","8","सरकारी अड्डा"]},{"id":"8","cell":["{}","","Y","","","9","म्यादवाला स्वयंम निबेदनबाट"]}]}
我还浏览了文件flexigrid.js
文件,并看到了一些针对JSON情况编写的代码:
I also went through file flexigrid.js
file and saw some code written for JSON case :
if (p.dataType == 'json') {
$.each
(
data.rows,
function (i, row) {
var tr = document.createElement('tr');
if (i % 2 && p.striped) tr.className = 'erow';
if (row.id) tr.id = 'row' + row.id;
//add cell
$('thead tr:first th', g.hDiv).each
(
function () {
var td = document.createElement('td');
var idx = $(this).attr('abbr');
td.align = this.align;
td.innerHTML = row.cell[idx];
$(tr).append(td);
td = null;
}
);
在此先感谢
Thanks in advance
推荐答案
(document).ready(新 function(){
(document).ready(new function(){
(" ).flexigrid ( { 网址:' registration/handlers/LoadUsers1.ashx', dataType:' json', colModel:[ {display:' tameliTypeID',名称:' span> TameliTypeID',宽度: 20 ,可排序:true,对齐:左侧'}, {display:' tameliTypeName',名称:' span> TameliTypeName',宽度: 180 ,可排序:true,对齐:左侧'} ], 搜索项目:[ {display:' TameliTypeID',名称:' span> TameliTypeID'}, {display:' TameliTypeName',名称:' span> TameliTypeName'} ], sortname:" , 排序顺序:" , usepager:是的, 标题:' Tameli List', useRp:是的, rp: 10 , showTableToggleBtn:是的, 宽度: 805 , onSubmit:addFormData, 高度: 200 } );
("#fgrdProduct").flexigrid ( { url: 'registration/handlers/LoadUsers1.ashx', dataType: 'json', colModel : [ { display: 'tameliTypeID', name: 'TameliTypeID', width: 20, sortable: true, align: 'left' }, { display: 'tameliTypeName', name: 'TameliTypeName', width: 180, sortable: true, align: 'left' } ], searchitems : [ { display: 'TameliTypeID', name: 'TameliTypeID' }, { display: 'TameliTypeName', name: 'TameliTypeName' } ], sortname: "TameliTypeName", sortorder: "asc", usepager: true, title: 'Tameli List', useRp: true, rp: 10, showTableToggleBtn: true, width: 805, onSubmit: addFormData, height: 200 } );
我的代码以以下格式返回json:
My code returns the json in the format :
{"page":1,"total":9,"rows":[{"id":"0","cell":["{}","","Y","","","1","बिद्युतीय"]},{"id":"1","cell":["{}","","Y","","","2","अदालतको तामेलदारद्वारा"]},{"id":"2","cell":["{}","","Y","","","3","अन्य अदालतको माध्यमद्वारा"]},{"id":"3","cell":["{}","","Y","","","4","प्रहरीद्वारा"]},{"id":"4","cell":["{}","","Y","","","5","पत्रपत्रिका"]},{"id":"5","cell":["{}","","Y","","","6","हुलाक"]},{"id":"6","cell":["{}","","Y","","","7","स्थानीय निकाय"]},{"id":"7","cell":["{}","","Y","","","8","सरकारी अड्डा"]},{"id":"8","cell":["{}","","Y","","","9","म्यादवाला स्वयंम निबेदनबाट"]}]}
我还浏览了文件flexigrid.js
文件,并看到了一些针对JSON情况编写的代码:
I also went through file flexigrid.js
file and saw some code written for JSON case :
if (p.dataType == 'json') {
.each ( 数据行 函数(i,行){ var tr = document.createElement(' tr'); 如果(i% 2 && p.striped)tr.className = ' 如果(row.id)tr.id = ' 行' + row.id; // 添加单元格
.each ( data.rows, function (i, row) { var tr = document.createElement('tr'); if (i % 2 && p.striped) tr.className = 'erow'; if (row.id) tr.id = 'row' + row.id; //add cell
这篇关于如何从json的“单元"显示所选参数.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!