Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#9694 closed enhancement (fixed)

Public API to change ItemFileReadStore url

Reported by: Josh Trutwin Owned by: Jared Jurkiewicz
Priority: high Milestone: 1.4
Component: Data Version: 1.3.2
Keywords: dojo.data.ItemFileReadStore clearOnClose Cc:
Blocked By: Blocking:

Description (last modified by bill)

Per #6073 there is a clearOnClose param since 1.2 that allows a data store to change URL's without having to create a new store. But for this to work you have to set a psuedo-private member of the class:

<div id="store" dojoType="dojo.data.ItemFileReadStore" clearOnClose="true" url="/foo.php">

then:

dijit.byId("store")._jsonFileUrl = "/bar.php";
dijit.byId("store").close();
dijit.byId("store").fetch();

Would it be possible to replace the first line with something like:

dijit.byId("store").setUrl("/bar.php");

Or even:

dijit.byId("store").attr('url', '/bar.php');

Thanks,

Josh

Change History (5)

comment:1 Changed 10 years ago by Josh Trutwin

oops - please add code formatting wiki tags...

comment:2 Changed 10 years ago by bill

Description: modified (diff)

comment:3 Changed 10 years ago by Jared Jurkiewicz

Resolution: fixed
Status: newclosed

This is already provided as of Dojo 1.4: http://bugs.dojotoolkit.org/ticket/9303

http://docs.dojocampus.org/dojo/data/ItemFileReadStore#reloading-refreshing-itemfilereadstore-from-a-url-dojo-toolkit-1-4

As for the secondary request for dijit.attr, that cannot be used. dijit.byId() works for widgets (classes that extend from dijit._Widget). None of the datastores extend from that class, they are not visual widgets, and therefore are not addressable by dijit.ById?(), nor would they have the attr function of dijit._Widget subclasses.

Anyway, long-winded comment on the dijit.ById? part, but as for setting the URL ,you already can:

storeInstance.url = <whatever>

The code has logic to trap that being reset, and if clearOnClose is true and close() was called, the new url value will be used.

So, already fixed.

comment:4 Changed 10 years ago by Josh Trutwin

Thanks for the nice comment - should've searched the bug database first. :(

Is .fetch(); needed still to automatically update the store after changing .url?

comment:5 Changed 10 years ago by Jared Jurkiewicz

Milestone: tbd1.4

The store will reload on the next call to fetch, either by a widget invoking it normally (As would ComboBox?, FilteringSelect?, etc, or by setting the query on grid, etc.).

Note: See TracTickets for help on using tickets.