DataModel and DataStore equivalencies - Ext JS

本文讨论了从ExtJS的Grid中获取数据的方法,包括如何通过DataStore和ColumnModel获取特定记录的数据,并展示了如何在更新数据后重新加载数据集。此外,还涉及如何使用RowSelectionModel和CellSelectionModel来处理选中行的数据。

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

Hello, very new to EXT here.

I was setting up some test last week to run yui-ext around the block. With Grid for example, I was able to grab the id (xmlDataModel) which I made meaningful:

grid.on('rowclick', function(grid, rowIndex) {
alert(grid.getDataModel().getRowId(rowIndex));
});

So, then I hear about EXT and 1.0. I have converted my testing rig to 1.0 but am at a loss when it comes to understanding DataStore (DataSource?)

I'm thinking in the neighborhood of:

grid.ds.getAt(rowIndex).ItemAt(id);

Obviosuly, no joy :-)

How would I achieve the equivalent of the above in 1.0 Alpha 2? Or, more generally, how would I access the data in any of the xml fields?


Also, I was able to load a new xml data set into the grid at will, by doing (anywhere on the page):

dm.load('url');

How does one achieve this?

Am I even close: ?

ds.loadData('url');


Lastly, anyone up for consulting? I've never had this much trouble finding paid help before in my life! Good Grief Charlie Brown....

TIA

Paul
Reply With Quote
  #2  
Old 02-28-2007, 11:03 PM
Default

maybe this will help:
var ds = grid.getDataSource(); // DataStore
var cm = grid.getColumnModel(); // ColumnModel
var r = ds.getAt(5); // 6-th Record from the DataStore
var colName = cm.getDataIndex(7); // name of the 8-th column from the Record
r.get(colName); // the record you want
Reply With Quote
  #3  
Old 02-28-2007, 11:48 PM
Default

Thanks, that worked like a charm.

Correct me if I am wrong, there is no DataStore documentation. I am not complaining, just making sure I am not missing some source of docs for this.

To get at a selected rows data:

var s = sm.getSelected();
var c = cm.getDataIndex(1);
alert(s.get(c));
Reply With Quote
  #4  
Old 03-01-2007, 12:17 AM
Default

yep. right now jack's not working on documentation much. more on bugs and features.
until then, we'll just have to dig into the source and rely on this forum for help.

another place to hunt would be the examples folder in the ext-1.0-alpha2.zip file.
there are already some great grid examples in there.

haven't really fiddled with the RowSelectionModel / CellSelectionModel, but from your example you should probably be looking at the CellSelectionModel.
Reply With Quote
  #5  
Old 03-07-2007, 11:40 AM
Default

Hi, I have a problem here maybe someone could help :d


I've used @mystix code, I have a PropertyGrid(new for PropsGrid) and after I edited a cell I want to save it in database.

The event function looks like this:

function afterEdit(propsG) {


var dso = propsG.getDataSource();
var cmo = propsG.getColumnModel();

var name = dso.getAt(0).get(cmo.getDataIndex(1));
var d1 = dso.getAt(1).get(cmo.getDataIndex(1));
var d2 = dso.getAt(2).get(cmo.getDataIndex(1));
var d3 = dso.getAt(3).get(cmo.getDataIndex(1));
var d4 = dso.getAt(4).get(cmo.getDataIndex(1));
var d4 = dso.getAt(5).get(cmo.getDataIndex(1));




// update new data
update( name, d1, d2, d3, d4, d5 );
}


The problem is: if I modify the "name" -
var name = dso.getAt(0).get(cmo.getDataIndex(1)); take the old value of name not the new value.

Thanks,
Cosmin.
Reply With Quote
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值