EXT grid只显示一条数据;

问题描述

/ 定义Proxyvar proxy = new Ext.data.HttpProxy({url : "plantsAction!getPlantsById.action"});var Order = Ext.data.Record.create([{name : "cabinetName",type : "string",mapping : "cabinetName"}, {name : "cabinetNO",type : "string",mapping : "cabinetNO"}, {name : "cabinetModel",type : "string",mapping : "cabinetModel"}, {name : "cabinetLocation",type : "string",mapping : "cabinetLocation"}, {name : "cabinetType",type : "string",mapping : "cabinetType"}, {name : "cabinetDutyRoleName",type : "string",mapping : "cabinetDutyRoleName"}, {name : "cabinetId",type : "string",mapping : "cabinetId"}, {name : "cabinetNotes",type : "string",mapping : "cabinetNotes"}, {name : "id",type : "int",mapping : "id",hidden : true}]);// 定义Readervar reader = new Ext.data.JsonReader({totalProperty : "totalCount",root : "data"}, Order);// 定义Storevar devstore = new Ext.data.Store({proxy : proxy,reader : reader});var devBoxAddrs = [["303", "303"], ["405", "405"]];// 定义列模型var cm = new Ext.grid.ColumnModel([{header : "机柜名称",dataIndex : "cabinetName",width : 120,align : "center",sortable : true}, {header : "机柜编号",dataIndex : "cabinetNO",width : 100,align : "center",sortable : true}, {header : "型号",dataIndex : "cabinetModel",width : 90,align : "center",sortable : true}, {header : "位置",dataIndex : "cabinetLocation",width : 100,align : "center",sortable : true}, {header : "规格类别",dataIndex : "cabinetType",width : 120,align : "center",sortable : true}, {header : "负责岗位",dataIndex : "cabinetDutyRoleName",width : 100,align : "center",sortable : true}, {id : "cabinetNotes",header : "描述",dataIndex : "cabinetNotes",width : 150,align : "center",sortable : true}]);// 分页控件 其实分页还是要后台控制的var pagingBar = new Ext.PagingToolbar({autoWidth : true,pageSize : 10,displayInfo : true,emptyMsg : "没有数据显示",displayMsg : "显示从{0}条到{1}条数据,共{2}条数据",store : devstore,loadMask : true});// 定义EditGridPanelvar useGrid = new Ext.grid.GridPanel({title : "已安装机柜列表视窗",store : devstore,cm : cm,// renderTo:"a",autoExpandColumn : "cabinetNotes",autoWidth : true,// height : 150,autoEncode : true, // 提交时是否自动编码tbar : ["-", {text : "增加机柜",icon : "../../../extjs/resources/images/default/dd/drop-add.gif",handler : function() {cabWin.show();}}, "-", {text : "删除机柜",icon : "../../../extjs/resources/images/default/dd/drop-no.gif",cls : "x-btn-text-icon",handler : function() {var sm = useGrid.getSelectionModel();if (sm.hasSelection()) {Ext.Msg.confirm("提示", "真的要删除选中的行吗?", function(btn) {if (btn == "yes") {var rsm = useGrid.getSelectionModel();// 得到行选择模型var cabid = 0;var view = useGrid.getView();var store = useGrid.getStore();for (var i = view.getRows().length - 1; i >= 0; i--) {if (rsm.isSelected(i)) {cabid = useGrid.getStore().getAt(i).get("cabinetId")+ "," + cabid;store.remove(store.getAt(i));}}alert(cabid);Ext.Ajax.request({url : "cabinetAction!deleteCabinet.action?ids="+ cabid,success : function(response, config) {Ext.Msg.alert("提示", "删除客户端成功");var view = useGrid.getView();var store = useGrid.getStore();view.refresh();alert(useGrid.getStore().getAt(0).get("cabinetId"));devstore.load({params : {plantId : useGrid.getStore().getAt(0).get("cabinetId"),start : 0,limit : 10}})},failure : function() {Ext.Msg.alert("result:", "get failed");},method : "get"})}});} else {Ext.Msg.alert("错误", "请先选择删除的行,谢谢!");}}}, "-"],bbar : pagingBar});后台输出的JSON数据{"data":[{"FState":0,"address":"","cabinetDutyRoleId":"1","cabinetDutyRoleName":"系统管理员","cabinetDutyUserID":"1","cabinetDutyUserName":"邢涛 ","cabinetId":"8","cabinetLocation":"36#","cabinetModel":"42U","cabinetNO":"1#","cabinetName":"专用机柜1","cabinetNotes":"888888888","cabinetType":"服务器机柜","countCabinet":0,"createTime":"","creatorId":0,"deptId":0,"deptName":"","id":0,"name":"","notes":"","plantsNO":"","purpose":""},{"FState":0,"address":"","cabinetDutyRoleId":"1","cabinetDutyRoleName":"系统管理员","cabinetDutyUserID":"1","cabinetDutyUserName":"邢涛 ","cabinetId":"2","cabinetLocation":"1","cabinetModel":"1","cabinetNO":"2","cabinetName":"1","cabinetNotes":"1","cabinetType":"1","countCabinet":0,"createTime":"","creatorId":0,"deptId":0,"deptName":"","id":0,"name":"","notes":"","plantsNO":"","purpose":""},{"FState":0,"address":"","cabinetDutyRoleId":"1","cabinetDutyRoleName":"系统管理员","cabinetDutyUserID":"1","cabinetDutyUserName":"邢涛 ","cabinetId":"6","cabinetLocation":"36#","cabinetModel":"42U","cabinetNO":"3#","cabinetName":"专用机柜2","cabinetNotes":"888888888fdsgad","cabinetType":"其他","countCabinet":0,"createTime":"","creatorId":0,"deptId":0,"deptName":"","id":0,"name":"","notes":"","plantsNO":"","purpose":""},{"FState":0,"address":"","cabinetDutyRoleId":"1","cabinetDutyRoleName":"系统管理员","cabinetDutyUserID":"1","cabinetDutyUserName":"邢涛 ","cabinetId":"9","cabinetLocation":"36#","cabinetModel":"42U","cabinetNO":"1#","cabinetName":"专用机柜1","cabinetNotes":"888888888","cabinetType":"服务器机柜","countCabinet":0,"createTime":"","creatorId":0,"deptId":0,"deptName":"","id":0,"name":"","notes":"","plantsNO":"","purpose":""}],"totalCount":4}但是页面只显示一条了;

解决方案

服务端返回的数据中每一条记录的id都是相同的,而JsonReader的idProperty默认配置是id,这就是出现问题的根源。你只要让每一条记录的id不同就行了。

时间: 2025-01-20 20:27:14

EXT grid只显示一条数据;的相关文章

用List绑定dataGridView 为什么我的只显示一条数据

问题描述 publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}privatevoidForm1_Load(objectsender,EventArgse){List<Staff>staff=newList<Staff>();Staffsf=newStaff();sf.ID=20090101;sf.Name="王小毛";sf.Age=19;sf.Sex="男";St

奇怪问题:datagrid不分页,不同页面间datagird和dropdownlist数据绑定相互影响,只显示10行数据?

问题描述 我这有4个页面,访问的是Sybase数据库中同一个数据库,但是操作的表不同.页面中有datagrid和dropdownlist控件,并且绑定数据库中的表的数据.但是不知道为什么?页面中datagrid原来分页的,但只显示10行数据,没有页码按钮.同时影响别的页面中的datagrid和dropdownlist的数据绑定也只显示10行数据.dropdownlist这个控件的绑定也只显示10条.奇怪的很?不知道为什么只显示10条数据? 解决方案 解决方案二:AllowPaging="True

sql-查询SQL数据只显示第一条不能全部显示

问题描述 查询SQL数据只显示第一条不能全部显示 现住客人房费一表 <% DataServer = "lx" DataUser = "sa" DataBaseName = "hy2006qt" DataBasePsw = "" Set conn = Server.CreateObject("ADODB.Connection") ConnStr="driver={SQL Server};ser

ext-为什么EXT grid不能显示数据?

问题描述 为什么EXT grid不能显示数据? 求解,为什么grid里面没有数据显示?各位大神帮帮忙 解决方案 你看下你的响应里面的Json数据的key值是不是dataIndex里面的值,应该是没对应上 解决方案二: 补充:整合DWR调用数据,打断点显示data能取到数据,但是为什么grid里面没有显示?

sql-SQL查询字段有重复只取一条数据

问题描述 SQL查询字段有重复只取一条数据 sql查询数据,其中一个字段的数据有重复,重复的数据其他字段除创建时间外都相同,重复数据如何只显示最新的那条数据? 解决方案 select * from t where 时间 in ( select max(时间) from table group by 相同字段1,相同字段2,相同字段3,.... ) 思路 : 查询字段相同的数据(group by 或 distinct) 然后取出时间最新 (max 或者 时间升序)的数据, 将以上结果放在临时表 然

extjs-查看grid中的一条数据. 如何获取radiogroup的值

问题描述 查看grid中的一条数据. 如何获取radiogroup的值 请问,我现在有一个grid. 我添加了一个人双击查看这条数据的事件. 但是在显示的form中,别的字段都是可以获取到的,只有radiogroup是获取不到. 找了一上午不知道为什么,麻烦各位大神给解答一下,谢谢 麻烦看下我的页面和代码. 麻烦各位大神给解答一下.非常感谢. 解决方案 console.log(gridRecord)看看sourceDataType字段内容是什么,自己对比下record的键名称sourceData

为什么只显示一条FLASH 记录呢!

问题描述 前台:<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml

eclipse-模糊搜索,为什么只显示一条信息,代码如下,请各位大侠帮帮忙吧

问题描述 模糊搜索,为什么只显示一条信息,代码如下,请各位大侠帮帮忙吧 Dim texts As StringDim mrc As ADODB.RecordsetSet mrc = New ADODB.RecordsetSet mrc = ExecuteSQL(txtsql1) 'If mrc.EOF = False Then With MSF1 .Rows = 22 .Row = 1 mrc.MoveFirst Do While Not mrc.EOF For i = 1 To 2 .Text

freemarker中的list遍历 ,我想实现每行只显示三个数据

问题描述 freemarker中的list遍历 ,我想实现每行只显示三个数据