PDA

View Full Version : how to get grid object from the container div.



sayeed
25 Dec 2006, 9:34 PM
Hi guys
Can any one plz let me know how to get grid from the container div to get the contect of the grid.
Any help in this regards will be appriciated.

jack.slocum
26 Dec 2006, 3:35 AM
Not sure I understand. Can you explain a little further?

sayeed
26 Dec 2006, 3:57 AM
How every u r thanks for giving me reply.I will let u know the problem i am facing.

Actually i am placing a grid in to the tab body.After placing the grid in to the tab contect,i wanna to read the read the contect of the grid.Here is the problem i dont know how to read the contect of the grid.Plz
give me the code of reading the contect of the grid row by row.since the grid is placed in the container div .please help me.

jack.slocum
26 Dec 2006, 4:28 AM
When you create the grid, you have a reference to it. You will need to store that reference for later use.

All of the examples in the example section use a strcuture fthat makes it easy to find your objects. You should probably try to use one of these structures.

sayeed
26 Dec 2006, 4:37 AM
Thanks for reply.Here is the code for creating grid this is placed in js file.


var UsersJSONGrid = { onLoad : function(){this.grid.getSelectionModel().selectFirstRow();},
init : function() { var schema = { root: 'Users', totalProperty: 'Total', id: 'user', fields: ['UserId','Name','Company','Login','Password','designation'] };
/*var data ={'Users':[ {'UserId': 'user123', 'Name':'Samba Siva Rao','Company':'PrapanSol','Login':'skolusu','Password':'welcome123'},
{'UserId': 'user456', 'Name':'Anil','Company':'PrapanSol','Login':'agolla','Password':'welcome'}]};*/
var data ={'Users':[ {'UserId': '323', 'Name':'Samba Siva Rao','Company':'PrapanSol','Login':'skolusu','Password':'welcome123','designation':'Developer'},{'UserId':'322','Name':'Sayeed','Company':'Prapansol','Login':'sbazahar','Password':'welocme123','designation':'Developer'},{'UserId': '326', 'Name':'Anil','Company':'PrapanSol','Login':'agolla','Password':'welcome','designation':'Web Designer'}]}
alert(data.Users.length);
alert("Name : "+data.Users[0].Name);
alert("Company : "+data.Users[0].Company);
alert("UserId : "+data.Users[0].UserId);
alert("Login : "+data.Users[0].Login);
alert("Password : "+data.Users[0].Password);
var columns= [{ header: "UserId", width: 110, sortable: true },{ header: "Name", width: 130, sortable: true },{ header: "Company", width: 125, sortable: true },{ header: "Login", width: 75, sortable: true },{ header: "Password", width: 105, sortable: true },{header:"Designation",width:105,sortable:true}];
this.dataModel = new YAHOO.ext.grid.JSONDataModel(schema);
this.colModel = new YAHOO.ext.grid.DefaultColumnModel(columns);
this.grid = new YAHOO.ext.grid.Grid('example-grid',this.dataModel, this.colModel);
this.grid.render();
this.grid.dataModel.loadData(data);}};
YAHOO.util.Event.on(window, 'load', UsersJSONGrid.init, UsersJSONGrid, true);



Here is the html div in the html file which is used as display grid.

<div id="example-grid" style="border: 1px solid #cccccc; overflow: hidden; width: 535px; height: 225px;"></div>


Now please suggest me how i can store the reference of the grid .Here in the html file i am writing javascript code to get the contect of the grid.So please suggest how to get the reference of the grid or how to store the reference of the grid.
please the code for javascript here.
<script type="text/javascript">


</script>
This java script code is to be placed in to the html file which is displaying the grid.

tryanDLS
26 Dec 2006, 9:38 AM
'this.grid' is the reference to the grid. If you don't understand how to use or store this for later use, you really need to go back and learn some javascript basics. Refer to the 'Javascript newbies help' thread in the Help forum for links to Javascript resources.

FYI in the future please post questions of this nature in the Help forum, not the Development forum.

sayeed
26 Dec 2006, 7:42 PM
Hi everybody
Finally i am able to read the contect of the grid.This is only possible by holding the reference of the
grid.Later by using the reference we can retrive the content.

sayeed
26 Dec 2006, 7:43 PM
Hi everybody
Finally i am able to read the contect of the grid.This is only possible by holding the reference of the
grid.Later by using the reference we can retrive the content.