PDA

View Full Version : creating new object of the class..



Dattaprasad
5 Jul 2010, 10:58 PM
Whot i hav done is that i have created a class of Gridpanel and i hav hard coded the store data with one array contents... Now the question is that if i create another object of that same class how can i change the store ->data contents by using the newly created object....


please help...

i am a new user to WTFJS....


thank you

Condor
5 Jul 2010, 11:13 PM
grid.getStore().loadData(otherData);
(but why hardcode data if you are planning on changing it later anyway)

Dattaprasad
6 Jul 2010, 12:20 AM
thanks a lot....

i was trying to load new array content via creating new object...

i mean new object created and then new array loaded into new grid and not in same grid...

:)

following is the code:

Wtf.onReady( function() {
//---------------------------------------------------------------------------------------------------------
var myData=[
['Datta','Pimpri',123456789,411044],
['anwar','Nigdi',789456134,411055],
['Kapil','Warje',564567891,411033]
];//mydata

var myData1=[
['abc','abc',123456789,411044],
['def','def',789456134,411055],
['pqr','pqr',564567891,411033]
];

var myData2=[
['asd','asd',123456789,411044],
['yui','dghfh',789456134,411055],
['bnm','pqrhhh',564567891,411033]
];

//----------------------------------------------------------------config
Wtf.myGridpanel = function(config){

Wtf.apply(this,config);

this.newData=Wtf.data.Record.create([
{name:'Name'},{name:'Address'},{name:'Phone'},{name:'Pin Code'}
]);

this.store=new Wtf.data.Store({
data:this.store1,
reader:new Wtf.data.ArrayReader({root:'newData'},this.newData)
});

this.colModel = new Wtf.grid.ColumnModel([
{header:'Name',width:120,sortable:true,dataIndex:'Name'},
{header:'Address',width:120,sortable:true,dataIndex:'Address'},
{header:'Phone',width:120,sortable:true,dataIndex:'Phone'},
{header:'Pin Code',width:120,sortable:true,dataIndex:'Pin Code'}
]);

this.cellSel=new Wtf.grid.CellSelectionModel();
//--------------------------------------------------------------
this.grid=new Wtf.grid.GridPanel({
store:this.store,
cm:this.colModel,
// layout:'fit',
width:500,
renderTo:document.body,
frame:true,
stripRows:true,
sm:this.cellSel
});

Wtf.myGridpanel.superclass.constructor.call(this,{items:this.grid});

this.cellSel.on('cellselect',this.ShowSelected,this);

};//myGridpanel close

Wtf.extend(Wtf.myGridpanel,Wtf.Panel,{

ShowSelected:function(){
var x=this.cellSel.getSelectedCell();
alert(x);
}
});


//-------------------object creation-------------------------
var myGridpanel=new Wtf.myGridpanel({
renderTo:document.body,
store1:myData,
autoScroll:true,
title:"My Grid Panel1",
width:500,
frame:true
});

var myGridpanel1=new Wtf.myGridpanel({
renderTo:document.body,
autoScroll:true,
store1:myData1,
title:"My Grid Panel2",
width:500,
frame:true
});

var myGridpanel1=new Wtf.myGridpanel({
renderTo:document.body,
autoScroll:true,
store1:myData2,
title:"My Grid Panel3",
width:500,
frame:true
});


//-------------------------------------------------------------
});//onready

Animal
6 Jul 2010, 12:41 AM
i am a new user to WTFJS....



I like that name. I think I'm going to write a Javascript library and call it that!

Dattaprasad
6 Jul 2010, 2:23 AM
lol

how cool is that!!!!

it was miswritten....

"EXTJS" it was...!!! :)

mystix
6 Jul 2010, 9:36 PM
I like that name. I think I'm going to write a Javascript library and call it that!

i think someone's already grabbed that name: :)
http://wtfjs.com/

(very interesting read though -- i highly recommend it)

makana
6 Jul 2010, 9:49 PM
i think someone's already grabbed that name: :)
http://wtfjs.com/

(very interesting read though -- i highly recommend it)

Nice little site!! It's the right name for that ;)

Dattaprasad
11 Jul 2010, 7:52 PM
as soon as i get a new name i'l surely suggest it to you....!!!

:)