Extjs开发遇到的问题之三

本文介绍ExtJS中GridPanel的无刷新提交、数值显示处理、TreePanel配置等实用技巧,并涉及Hibernate与Oracle的数据交互注意事项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

   1,Extjs在前台修改GridPanel中记录后无刷新提交到后台,保存至数据库。

    

引入<%String path = request.getContextPath();%>
<script type="text/javascript" src="<%=path%>/ext-3.2/examples/ux/RowEditor.js"></script>
<link rel="stylesheet" type="text/css" href="<%=path%>/ext-3.2/examples/ux/css/RowEditor.css"/>

  

var editor = new Ext.ux.grid.RowEditor(); 
editor.on({ 
    scope: this, 
    afteredit: function(roweditor, changes, record, rowIndex) { //编辑某行
	Ext.Ajax.request({ 
		url   : '<%=path%>/myAction!updateData.ilf', 
		method: 'post', 
		params: {thresholdUp:changes['thresholdUp'],thresholdDown:changes['thresholdDown'],id:record['id']}, 
	    	success: function() {dosth....//可重新加载数据} 
    	}); 
    } 
});
 var aGrid = new Ext.grid.GridPanel({
    id:'aGridId',
    plugins: [editor], 
    store: dataStore,
    cm: cmA,
    sm: smgroup,
  });
var cmA = new Ext.grid.ColumnModel([
  smgroup,
  {header:'地市'	,dataIndex:'cityName'},
  {header:'性能指标'	,dataIndex:'performanceParamName'	},
  {header:'性能下限门限值'	,dataIndex:'thresholdDown'	,editor: new Ext.form.NumberField()},
   {header:'性能上限门限值'	,dataIndex:'thresholdUp'	,editor: new Ext.form.TextField()}]);

  2,进行Extjs开发,小数点前面0不显示。
      在页面上编辑小数时,如果为类似 0.1的值,最后提交后在前台显示时是 .1,自动去掉了0。
     实际上是从数据库中取出来,转为json前就是 .1了,因为在oracle中对应该字段是number类型,而java中是string类型,现在hibernate中改为<property name="thresholdDown" column="threshold_down" type="big_decimal"/>
对象中改为java.math.BigDecimal,在前台显示正常。因此还是要注意,数据表中字段什么类型,hibernate中尽量是什么类型。

 

  3,对于前台输入,页面上限制输入,只要求是数字,用Ext.form.NumberField。

 

  4,GridPanel中:
      var rows = Ext.getCmp('aGridId').getSelectionModel().getSelections();
   和var rows = aGrid.getSelectionModel().getSelections();意思相同。
     alert(rows[i].data.id);

   和alert(rows[i].get('id'));意思相同

 

  5,1》hibernate删除多条记录的一个方法(extjs开发时也用到了):

 

String ids = object.getIds();
if(AppUtil.isNotNull(ids)){
	String int_ids[] = ids.split(",");
	List list = new ArrayList();
	for (String int_id : int_ids) {
		RmsPerThresEarlyalarmKpi obj = new RmsPerThresEarlyalarmKpi();
		obj.setId(Integer.valueOf(int_id));
		list.add(obj);
	}
	getHibernateTemplate().deleteAll(list);
}

      2》no persistent classes found for query class错误:hibernate中是否有对应的类,及对应的hbm文件

  6,Ext.tree.TreePanel多级显示是否有叶子显示。loader加载时返回的json中leaf:true是叶子。

  7,Ext.ComponentMgr.all.each(function(r){alert(r.id)});    把所有的组件的id打出来

      TextField:fieldLabel:标签名称。 labelWidth:标签宽度。

  8,页面显示为table页形式

 

//先设置一个TabPanel,renderTo: 'main'指向 
<body >
  <div id='form'></div>
  <div id='main'></div>
  </body>
//在js中
var gridpanel= new Ext.Panel({
	 title: '查询信息',
	 collapsible: true,
	 collapsed: false,
	 items:[grid]
});
 var tabs = new Ext.TabPanel({
 	height:400,
 	title: '设定',
 	collapsible: true,
 	collapsed: false,
 	renderTo: 'main'
 });
 tabs.add({id: Ext.id(),	title:'列表',items:[gridpanel]});
 tabs.activate(0);//默认显示第一个tab标签

  

   9,两个char类型的用==比较就行,比较的是值。
       String ids = "aa,";
       ids.charAt(ids.length()-1)==','
-----------
      if(ids.lastIndexOf(",")==ids.length()-1)

  

   10,如果提示信息出不来,需加上Ext.QuickTips.init(); 在 Ext.onReady(function(){后面

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值