Get selectboxes inside datagrid working

This commit is contained in:
Nathan Gray 2012-03-13 23:02:21 +00:00
parent 5284844780
commit 6426b2d2db
2 changed files with 10 additions and 13 deletions

View File

@ -40,25 +40,22 @@ var et2_arrayMgr = Class.extend({
}
// Expand sub-arrays that have been shmushed together, so further perspectives work
// Shmushed keys look like: ${row}[info_cat]
// Expanded: ${row}: Object{info_cat: ..value}
if (this.splitIds)
{
// For each index, we need a key: {..} sub array
for(var key in _data) {
// Split up indexes
var indexes = key.split('[');
if (indexes.length > 1)
{
indexes = [indexes.shift(), indexes.join('[')];
indexes[1] = indexes[1].substring(0,indexes[1].length-6);
var children = indexes[1].split('[]');
if(children.length)
{
indexes = jQuery.merge([indexes[0]], children);
}
}
// Put data in the proper place
if(indexes.length > 1)
{
var value = _data[key];
var target = _data;
for(var i = 0; i < indexes.length; i++) {
indexes[i] = indexes[i].replace('&#x5D;','');
if(typeof target[indexes[i]] == "undefined") {
target[indexes[i]] = i == indexes.length-1 ? value : {};
}

View File

@ -81,7 +81,7 @@ var et2_selectbox = et2_inputWidget.extend({
return;
}
var name_parts = this.id.replace(/]/g,'').split('[');
var name_parts = this.id.replace(/&#x5B;/g,'[').replace(/]|&#x5D;/g,'').split('[');
// Try to find the options inside the "sel-options" array
if(this.getArrayMgr("sel_options"))
@ -89,8 +89,8 @@ var et2_selectbox = et2_inputWidget.extend({
// Select options tend to be defined once, at the top level, so try that first
var content_options = this.getArrayMgr("sel_options").getRoot().getEntry(name_parts[name_parts.length-1]);
// Try again according to ID
if(!content_options) content_options = this.getArrayMgr("sel_options").getEntry(this.id);
// Try again according to ID, but strip any encoded ][
if(!content_options) content_options = this.getArrayMgr("sel_options").getEntry(this.id.replace(/&#x5B;/g,'[').replace(/&#x5D;/g,']'));
if(_attrs["select_options"] && content_options)
{
_attrs["select_options"] = jQuery.extend({},_attrs["select_options"],content_options);