View Full Version : keeping datasets seperate
thecow
05-10-2004, 06:54 AM
I have a class that has grids inside of it. I am having problems when I call multiple instances of this class. I will call data on the first instance of the class, and the most recent instance grabs the data. Is there someway to make sure to give the data to a certain grid instead of the most recent one getting it?
Thanks for any help.
***edit
Ok, after futher looking, all of the classes are getting the data, so what I need is a way to make sure only the current grid updates it's data.
Also, can I use script to declare a persistent variable that is local to a class so that I can use it in dataset queries?
antun
05-10-2004, 09:14 AM
If I remember correctly, you have to manually call updateData() on the datapath of whatever is bound to your data, for it to reflect in the dataset.
So you could check for whether this is the current grid (using a flag variable) and only call updateData then.
Are you seeing the behavior I described, or is it updating the data regardless?
-Antun
thecow
05-10-2004, 09:55 AM
It's automatically updating the way I have it set up,
but you may know of a different way so that I can implement the updatedata() method.
Here is what I have at the moment.
<canvas>
<dataset type="http" name="orderSrv" src="http://service.cfm" />
<command id="cmd_new_so" onselect="new orders_window(canvas,{title:'Sales Orders', name:'anon', resizable:true, closeable:true})"/>
<class name="orders_window" extends="window">
<grid name="mygrid" datapath="orderSrv:/*" >
<gridtext datapath="@attr1">Column1</gridtext>
<gridtext datapath="@attr2">Column2</gridtext>
<gridtext datapath="@attr3">Column3</gridtext>
</grid>
<button>
<method event="onclick">
var d = canvas.datasets.orderSrv;
d.setQueryString( { target : myvar } );
d.doRequest();
</method>
</button>
</class>
<menu name="main_mnu">
<menuitem text="New SO Window" command="cmd_new_so"/>
</menu>
</canvas>
This is the structure I am using to create multiple windows with grids.
When I click on the button, it updates the dataset, and the grids automatically update.
Since I will be sending different query parameters with different windows,
I need to make sure on the current grid updates.
Hopefully you can tell me a better way to go about this. Thanks!!
antun
05-10-2004, 10:15 AM
Check out last week's tip:
http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=878
Putting a <text> field inside of a <gridcolumn> is pretty much what <gridtext> gets you, except that with <gridtext> you get all the editing functionality you expect with a grid.
You could write an onclick event handler that called the parent's (i.e. the grid's) select() method to select the row, at the same time as checking the flag variable, and if necessary popping up a text field where necessary.
-Antun
thecow
05-10-2004, 10:26 AM
I'm very sorry, but I am a little confused by your reply. I am wanting to keep the data in the grids from updating, unless I hit the update button on that page. Is this the question you were trying to answer?
antun
05-10-2004, 11:03 AM
Yes - that's what I was answering, but maybe I was jumping ahead a little.
By default, the edittext component (i.e the text input box) that you see when you click on a grid cell won't reflect changes in the data it's bound to, unless you call its updateData method.
However the gridtext class looks like it's set up to automatically call updateData() in the edittext instance (either when the user clicks away or when the edittext instance sends its ontext event - the latter would mean it calls it on every keystroke pretty much).
Given that, if you want to have a custom grid where a cell that is clicked on does not automatically call updateData(), you need to write your own class that does more or less what <gridtext> does. Essentially, that means a <gridcolumn> containing a <text> field, with extra functionality to show an editable text region as required.
-Antun
Originally posted by thecow
I am wanting to keep the data in the grids from updating, unless I hit the update button on that page. Is this the question you were trying to answer?
thecow
05-10-2004, 12:51 PM
I have just realized that we are talking about two different things.
You are telling me how to keep the dataset from updating when data in the grid is changed.
I am trying to keep the grid from changing everytime a call is made on the dataset.
For example:
Say I have alot of data which contains integers, and I have a grid to display and filter this data.
Now say I want to see multiple sets of filtered data at the same time(i.e. >10 or <10 or multiples of 3, or whatever), so I put the grid in a class.
As it stands, when I load a new class with a new querystring to filter it, the data that is returned is loaded into every class/grid that I have running and kills the purpose of multiple grids.
I want to only have the grid reload the dataset when I tell it to.
Does this make more sense?
antun
05-13-2004, 04:11 PM
I think you're only going to get that kind of behavior by copying over the contents of one dataset to a new buffer dataset, and pointing the new grid to the buffer one.
The idea behind databinding is to cause whatever is bound to data to update whenever the underlying data updates.
See this for how to copy nodes across:
http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=222
-Antun
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.