PDA

View Full Version : How to name my stores / grids in function?



scblue
1 Mar 2010, 12:06 AM
Hi all,

I am having a little problem. I have writing a general function to display different grids.

I am able to display a single grid via metadata just fine.

Now I've got to put everything into a function.

For e.g.




creategrid('jobs'); // or tasks / cats / etc

function creategrid(t){

var type = t; //type of grid needed

jstore = new Ext.data.JsonStore({ ... }); //how do I name my store?

}

I have a few tables i.e. jobs, categories, tasks, etc.

How to name my stores / grids according to the parameters passed into the functions?

I did :




function creategrid(t){

var type = t; //type of grid needed

type = new Ext.data.JsonStore({ ... }); //this doesn't work tho.

}


but it didn't work.

Thanks in advance~!

mitchellsimoens
1 Mar 2010, 3:46 PM
var grids = new Array();
function creategrid(t) {
grids[t] = new Ext.data.JsonStore({ ... });
}

scblue
1 Mar 2010, 5:05 PM
var grids = new Array();
function creategrid(t) {
grids[t] = new Ext.data.JsonStore({ ... });
}

You're a genius. B)
I'll give it a try and see if I can make it work.

Thanks!!!

mitchellsimoens
1 Mar 2010, 5:22 PM
You're a genius. B)

Well :"> I wouldn't necessarily say that..... lol

Just keep things simple

scblue
1 Mar 2010, 11:31 PM
Thanks a lot!
It worked like a charm.
I don't know why I didn't think of that. ;)

Now I can finally move on with other codes.

Thanks again!