[Dojo-checkins] [dojo] #10323: Dojox grid adds new item regardless of whether it matches query.
dojo
trac at dojotoolkit.org
Thu Nov 12 11:22:06 EST 2009
#10323: Dojox grid adds new item regardless of whether it matches query.
------------------------+---------------------------------------------------
Reporter: alemik | Owner: toonetown
Type: defect | Status: new
Priority: normal | Milestone: 1.4
Component: DojoX Grid | Version: 1.3.2
Severity: major | Keywords: dojox grid query
------------------------+---------------------------------------------------
Hi all,
I'm having a problem with dojox grid.
I have a following grid:
{{{
var myLayout = [
{
name : this.dict[ "use" ],
width : "auto",
styles : "text-align: center",
type : dojox.grid.cells.Bool,
field: "selected",
editable : !this.ro
},
{
name : this.dict[ "form" ],
field : "title",
width : "175px"
},
{
name : this.dict[ "description" ],
field : "description",
width : "325px"
},
{
name : this.dict[ "instances" ],
field : "tempInstanceCount",
width : "70px"
}
];
this.grid = new dojox.grid.DataGrid({
id : "groupAdminGrid",
store : this.store,
query : { type : "form" },
queryOptions : { deep : true },
structure : myLayout,
style : "width : 650px; height : 300px;"
});
}}}
When I add new item to store, it appears in the grid as well, regardless
of the "type" attribute.
So for example I might end up with groups or image items in a list where I
should have only forms.
{{{
this.store.newItem(
{
id : myId,
type : "formreference",
<some more attributes>
},
{
parent : formgroupItem,
attribute : "children"
});
}}}
Would it make sense to validate the query attribute when adding new item
in the grid?
For example make _onNew function to fetch all the items that match the
query and then check for the keys?
Eventually I just overrode the _onNew function in dojox.grid.DataGrid with
my own:
{{{
/**
* Validates whether there is any matching key item to be added in query
used or if it uses wildcard,
* if true - add a new item.
*/
_onNew : function(item, parentInfo)
{
for( var key in this.query )
{
if( this.query[key] == '*' ||
this.query[key] == this.store.getValue( item, key ) )
{
var rowCount = this.attr('rowCount');
this._addingItem = true;
this.updateRowCount(rowCount+1);
this._addingItem = false;
this._addItem(item, rowCount);
this.showMessage();
break;
}
}
}
}}}
I'm not sure though whether each item will have a store and query - they
do in application I'm currently work on, so I've omitted the checks of
whether those things exist or not.
--
Ticket URL: <http://bugs.dojotoolkit.org/ticket/10323>
dojo <http://dojotoolkit.org/>
The Dojo UI Toolkit
More information about the Dojo-checkins
mailing list