在Dojo datagrid中添加一行 [英] Add a row in Dojo datagrid

查看:194
本文介绍了在Dojo datagrid中添加一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何添加一行并清除Dojo datagrid(1.4.2版)中的所有行。让我们说数据是2列,包含customerID和地址。



我正在使用

  dojo.data.ItemFileWriteStore 

存储值 - 但不太确定如何应该使用。



不能那么难。



干杯。 $ b

解决方案

您可以使用 grid.store 从网格获取数据存储引用,然后可以使用 store.newItem()在商店中创建一个新项目。该新项目作为新的行添加到网格中。例如, store.newItem({customerID:1,address:Somewhere})



要清除所有行都可以循环使用数据存储中的所有项目,并使用 deleteItem()删除所有项目,或使用内部函数 _clearData()在数据网格中删除所有行,或使用 setStore()设置一个新的空存储到网格。我更喜欢使用一个空的商店来重置网格。


Struggling to find a bit of code to easily understand.

How do you add a row and clear all rows in a Dojo datagrid (version 1.4.2). Lets say the data is 2 columns with customerID and address.

I am using

dojo.data.ItemFileWriteStore

to store values in - but again not quite sure how this should be used.

It can't be that hard.

Cheers.

解决方案

You can get the data store reference from the grid using grid.store, then you can use store.newItem() to create a new item in the store. This new item is added as a new row in the grid. For example, store.newItem({customerID : 1, address : "Somewhere"}).

To clear all the rows, you can either loop all the items in the data store and use deleteItem() to remove all the items, or use the internal function _clearData() in data grid to remove all the rows, or use setStore() to set a new empty store to the grid. I prefer to use a empty store to reset the grid.

这篇关于在Dojo datagrid中添加一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆