I wanted to use some of the ListGrid functionality in a FormItem so I created a FormItem that uses a ListGrid instead of a NativeSelectItem. However, when I put this into a DynamicForm and call DynamicForm.getValues(), I get empty values for these ListItems regardless of what is selected. On the other hand, if I call ListItem.getValue() I get the value just fine. Any idea what I'm doing wrong? My code follows:
Code:
// EditableCanvasItem: overloaded CanvasItem with editable values isc.ClassFactory.defineClass("EditableCanvasItem","CanvasItem"); isc.EditableCanvasItem.setProperties({ shouldSaveValue:true,isEditable: function() { return true; } }); // ListItem: overloaded CanvasItem to display a ListGrid as a list box isc.ClassFactory.defineClass("ListItem","EditableCanvasItem"); isc.ListItem.addProperties({ init: function() { this.valueIndex={}; this.canvas=isc.VLayout.create({ width:"100%",height:"100%", members:[ isc.Label.create({contents:this.title,autoFit:true,wrap:false}), this.list=isc.ListGrid.create({ width:"100%",height:"100%",showHeader:false,canDragSelect:true, fields:[ {name:"value",visibility:"hidden"}, {name:"displayValue",width:"100%"} ] }) ] }); this.Super("init",arguments); }, getValue: function() { var selectedRecords=this.list.getSelection(); var values=[]; for (var iRecord=0;iRecord<selectedRecords.length;iRecord++) { values[iRecord]=selectedRecords[iRecord].value; } return values; }, setValue: function(value) { this.list.deselectAllRecords(); if (isc.isAn.Array(value)) for (var i=0;i<value.length;i++) this.list.selectRecord(this.valueIndex[value[i]]); }, getValueText: function() { return this.getValue().toString(); }, setListData: function(data) { var listData=[]; for (var iValue=0;iValue<data.length;iValue++) { if (data[iValue].DisplayValue) listData[iValue]={value:data[iValue].Value,displayValue:data[iValue].DisplayValue}; else listData[iValue]={value:data[iValue].Value,displayValue:data[iValue].Value}; this.valueIndex[data[iValue].Value]=iValue; } this.list.setData(listData); } });
Comment