View Full Version : Changing the Source of a Dataset at Run-time
antun
10-21-2003, 11:18 AM
If you need to set or change the actual source (e.g. XML file) of a dataset at runtime, then you can call setAttribute() on the src attribute, and set the dataset to request data over HTTP:
<canvas debug="true">
<dataset name="foo" src="data_file_one.xml"
type="http" autorequest="true" />
<simplelayout axis="y" spacing="5" />
<button>Serialize the Dataset
<method event="onclick">
debug.write( foo.getPointer().serialize() );
</method>
</button>
<button>Switch to data_file_two.xml
<method event="onclick">
foo.setAttribute( 'src', 'data_file_two.xml' );
foo.doRequest();
</method>
</button>
</canvas>
Enjoy!
a_ilyin
02-14-2005, 03:44 AM
What about grid?
Your approach don't work with grid if new XML has another structure because grid header don't update its header on changing data.
I workaround this manualy deleting old header. Is my solution is good. Is there other solutions?
<grid name="rightPane" width="${parent.width-treeView.width-10}"
height="${parent.height}" datapath="contactsData:/*"
showhscroll="true">
<method event="ondata">
<![CDATA[
var colCount = this.columns.length;
for(i=0;i<colCount;i++) {
this.columns[i].destroy();
}
this.columns=[];
this.init();
]]>
</method>
</grid>
huntedman
10-04-2005, 04:32 AM
How do I select an item (row) from code...
FI have this mailbox with a tree (mail folders) and a grid (messages). When a user clicks a folder, I want the grid to select the first message...
Thanx,
Arthur.
jsuen
10-15-2005, 06:39 AM
@huntedman: you can try selecting the first node of the array returned by your grid's dataset (or datapath array).
perspolis
10-07-2007, 11:45 PM
Hi,
Destroying the coloumn and setting back to initialize does not work for me because the size of grid coloumn size does not stay the same and i also have checkbox in one of the columns which will be destroyed too.
any other solution?
thanks,
balri
10-18-2007, 10:28 PM
If you need to set or change the actual source (e.g. XML file) of a dataset at runtime, then you can call setAttribute() on the src attribute, and set the dataset to request data over HTTP:
Enjoy!
I am trying to do this but get the src name from an XML file. Whenever I do I get an error saying "couldn't find dataset for prodSects:/sections/section"
My code looks like this:
<attribute name="filename" value="$path{'@filename'}" />
<dataset id="prodSects" name="prodSects" />
<handler name="oninit">
prodSects.setAttribute('src', filename);
prodSects.doRequest();
</handler>
The filename attribute is retrieved from another XML file and I can write this to the debugger without any problems. The code above is within a tabslider. I have put debugging comments in and confirmed that it's executing.
Any ideas what I'm doing wrong?
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.