Grid 如何使用TooltipDialog(和DropDownButton)更新Dojo网格单元值
我有一个dojo网格,它使用一些可编辑的dijit表单字段。一切都很好,直到我尝试实现一个国家(多)选择单元作为工具提示对话框;i、 例如,显示一个下拉按钮,打开填充有复选框数组的工具提示对话框,以选择一个或多个国家。选中并单击“确定”后,单元格应更新为选定国家的列表。显然,稍后我将负责通过应用商店更新服务器 我已经实现了一个“国家/地区选择”工具提示对话框,其工作原理如下:Grid 如何使用TooltipDialog(和DropDownButton)更新Dojo网格单元值,grid,dojo,Grid,Dojo,我有一个dojo网格,它使用一些可编辑的dijit表单字段。一切都很好,直到我尝试实现一个国家(多)选择单元作为工具提示对话框;i、 例如,显示一个下拉按钮,打开填充有复选框数组的工具提示对话框,以选择一个或多个国家。选中并单击“确定”后,单元格应更新为选定国家的列表。显然,稍后我将负责通过应用商店更新服务器 我已经实现了一个“国家/地区选择”工具提示对话框,其工作原理如下: dojo.provide("CountrySelector"); dojo.declare( "Countr
dojo.provide("CountrySelector");
dojo.declare(
"CountrySelector",
[dijit.form.DropDownButton],
{
label: 'Countries',
dropDown: new dijit.TooltipDialog({ execute: function() {
console.log("EXECUTE : ", arguments[0]);
this.value = arguments[0].country;
}, href:'/cm/ui/countries' }),
postCreate: function() {
this.inherited(arguments);
this.label = this.value;
dojo.connect(this.dropDown, 'onClose', function() { console.log('close'); });
console.log("CountrySelect post create", this);
},
}
);
网格单元的类型为:
{ name: 'Countries', field: 'targeting.countries', editable: true, hidden: false, type:dojox.grid.cells._Widget, widgetClass: CountrySelector },
一切都很好,但我不知道如何更新单元格的内容和存储一旦小部件被执行。此外,我似乎没有更新行的行id
有什么想法吗
谢谢,
Harel我没有用您的代码设置测试,但是您应该能够通过在您的小部件中创建一个名为
getValue
的方法来完成,该方法返回值
查看其他示例(如dojox.grid.cells.ComboBox),了解getValue应该是什么样子。这是我用来更新网格的
//Layout:
gridLayout: {rows: [{name: 'Coll Name',field: 'colField', type: dojox.grid.cells.ComboBox, editable:'true', width:'8%',options: [], alwaysEditing:false}]}
//Grid Store:
this.gridStore = new dojo.data.ItemFileReadStore({data: {items: data}});
//
var setOptions = function(items, request){
this.gridLayout.rows[0].options.push('Val 1','Val 2');
this.gridLayout.rows[0].values.push('1','2');
dojo.connect(this.gridLayout.rows[0].type.prototype.widgetClass.prototype, "onChange",this, "_onComboChange");
}
this.gridStore.fetch({onComplete: dojo.hitch(this,setOptions)});
_onComboChange: function (selectedOption) {
console.info("_onComboChange: ",selectedOption);
},
// If you need to populate combos with different values you can use onItem
var getArray = function(item, request){
// populate one by one
// attach an event to each combo
}
this.gridStore.fetch({onItem: dojo.hitch(this,getArray)});
var idx = yourGrid.getItemIndex(item);
if (idx >- 1) {
yourGrid.updateRow(idx);
}
更多细节
每一行都由其标识符标识
yourGrid.store.fetchItemByIdentity({
identity: <yourIdentity>,
onItem: function(item){
// Update your attributes in the store depending on the server response
// yourGrid.store.setValue(item, <attribute>,<value>);
var idx = yourGrid.getItemIndex(item);
if (idx >- 1) {
yourGrid.updateRow(idx);
}
}
});
yourGrid.store.fetchItemByIdentity({
身份:,
onItem:功能(项目){
//根据服务器响应更新存储中的属性
//yourGrid.store.setValue(项,);
var idx=yourGrid.getItemIndex(item);
如果(idx>-1){
yourGrid.updateRow(idx);
}
}
});
这对我来说从来都不起作用。在我的例子中,最终的解决方案(解决这个问题和其他问题)是抛弃Dojo(我非常喜欢),将所有东西都转移到ExtJs。就稳定性和易用性而言,它仅领先几英里。更不用说它实际上有合适的文档。谢谢你的帮助!