[Dojo-interest] Any way for grid to handle json where items objects can have one or more non-primitives?

Jared Jurkiewicz jared.jurkiewicz at gmail.com
Tue Apr 7 15:04:51 EDT 2009


It was assumed the default because at the development time of
ItemFile*Store, there was no datagrid.  There was ComboBox and Tree.
Most of the input on the store came from them during development.

Anyway:

http://bugs.dojotoolkit.org/ticket/9077

I just committed in a flag for it.  It took exactly 5 lines of code to
do it (one prop def, a constructor check, and  flag check when items
are processed to not process child JS objects if the flag is set on
load of data ), plus all associated UT.

Also updated docs:
http://docs.dojocampus.org/dojo/data/ItemFileReadStore



On Mon, Apr 6, 2009 at 3:11 PM, David M. Karr
<davidmichaelkarr at gmail.com> wrote:
> Jared Jurkiewicz wrote:
>> That's not a bug of IFRS.  IFRS always recurses down into child items;
>> its part of its design.  all child javascript objects themselves are
>> treated as DataStore items as well.  That's how it does hierarchy
>> support.
>>
>> See:
>> http://docs.dojocampus.org/dojo/data/ItemFileReadStore
>> http://docs.dojocampus.org/quickstart/data/usingdatastores/faq#question-10-in-one-of-my-items-in-itemfilereadstore-i-defined-an-attribute-value-as-a-javascript-object-but-i-didn-t-set-an-identifier-the-store-blows-up-with-an-error-about-no-identifier-when-fetching-why-does-it-care
>>
>> See the last URL (Faq entry), for suggestions.
>
> Just so it's clear, I wasn't suggesting this was a "bug" in IFRS, just
> that it's presenting a problem for me.
>
> I do wonder why hierarchical support is assumed as the default, as I
> would think that would be somewhat less common than non-hierarchical.
> That is, I would assume that grids are more common than trees, and
> hierarchical grids would be less common then non-hierarchical ones.
>
> It would have seemed logical to me to have a flag on the store like
> "hierarchical", which when set to "false" would not descend into items
> to find other items.
>
>> On Mon, Apr 6, 2009 at 12:19 PM, David M. Karr
>> <davidmichaelkarr at gmail.com> wrote:
>>> Jared Jurkiewicz wrote:
>>>> You can assign a 'formatter' function for a cell that allows you to
>>>> manipulate the value from the item however you like.
>>>>
>>>> -- Jared
>>> Yes, I can see that works.  I was even able to add two different columns
>>> that reference the same field, extracting different data from the single
>>> field.
>>>
>>> However, none of this works unless I install a manual patch for
>>> ItemFileReadStore, as described here:
>>> <http://www.dojoforum.com/2008/12/09/dojo-data-store-and-json-data-typeerror-arrayofvalues-undefined>.
>>>
>>> Without this patch, I see the following returned to my "onError"
>>> callback for the store fetch:
>>>
>>> TypeError: arrayOfValues is undefined
>>>
>>> and nothing gets populated into my grid (because the onComplete callback
>>> wasn't called).
>>>
>>> The error appears to happen because of a mechanism in IFRS which
>>> recursively iterates through the items list, creating the
>>> "arrayOfAllItems" list. When it finds a top-level item, it adds that to
>>> the list.  That is what I would expect.  However, it descends into that
>>> item and if it finds another non-primitive, it appears to add THAT to
>>> the "arrayOfAllItems" list also (as shown in function
>>> "addItemAndSubItemsToArrayOfAllItems"). As my "identifier" field is only
>>> defined in the top-level item, when it gets to this block of code (with
>>> the workaround commented out):
>>>
>>>                        for(i = 0; i < this._arrayOfAllItems.length; ++i){
>>>                                item = this._arrayOfAllItems[i];
>>>                                arrayOfValues = item[identifier];
>>>                                //if (!arrayOfValues)
>>>                                //{
>>>                                //      console.warn("this item [" + item + "] has no value for the
>>> identifier \"" + identifier + "\".");
>>>                                //      continue;
>>>                                //}
>>>                                var identity = arrayOfValues[0];
>>>
>>> it throws that error on the last line of this excerpt.
>>>
>>> I don't know what I'm supposed to do about this.
>>>>
>>>> On Sun, Apr 5, 2009 at 8:35 PM, David M. Karr
>>>> <davidmichaelkarr at gmail.com> wrote:
>>>>> I'm now trying to set up a grid that shows two columns.  One of them
>>>>> reflects the value of a primitive in the "item", and one of them
>>>>> reflects the value of a primitive in a nested object in the item.  I've
>>>>> had no real trouble with json structures where the item is all
>>>>> primitives, but this is the first time I've had an item that had at
>>>>> least one non-primitive, and it's causing me various problems.  Is it
>>>>> possible to handle this scenario, or do I have to produce a "normalized"
>>>>> json for this where the item object is all primitives?  Before I start
>>>>> detailing the problems I'm having, I'd like to know whether it's even
>>>>> possible (examples would be very useful).
>>>>> _______________________________________________
>>>>> FAQ: http://dojotoolkit.org/support/faq
>>>>> Book: http://dojotoolkit.org/docs/book
>>>>> Forums: http://dojotoolkit.org/forum
>>>>> Dojo-interest at mail.dojotoolkit.org
>>>>> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>>>>>
>>>> _______________________________________________
>>>> FAQ: http://dojotoolkit.org/support/faq
>>>> Book: http://dojotoolkit.org/docs/book
>>>> Forums: http://dojotoolkit.org/forum
>>>> Dojo-interest at mail.dojotoolkit.org
>>>> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>>> _______________________________________________
>>> FAQ: http://dojotoolkit.org/support/faq
>>> Book: http://dojotoolkit.org/docs/book
>>> Forums: http://dojotoolkit.org/forum
>>> Dojo-interest at mail.dojotoolkit.org
>>> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>>>
>> _______________________________________________
>> FAQ: http://dojotoolkit.org/support/faq
>> Book: http://dojotoolkit.org/docs/book
>> Forums: http://dojotoolkit.org/forum
>> Dojo-interest at mail.dojotoolkit.org
>> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://dojotoolkit.org/docs/book
> Forums: http://dojotoolkit.org/forum
> Dojo-interest at mail.dojotoolkit.org
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>


More information about the Dojo-interest mailing list