javascript - How to get key and value from a js map -


i trying write custom grid in jquery took @ jquery plugin development. in assigned headers grid , want assign rows, need assigning values rows.

var headers=new array(); headers=["name","host name","description","type","last update time"]; 

i thought of creating array of maps below, assigned rows in grid, need in understanding how assign. similar headers these rows can generic.

var myrows = [                 {cfgid:0, name:"lukas arts",host:"baxton", description:"test",type:"dev",updatedate:"thu apr 26 04:31:10 ist 2012"},                 {cfgid:1, name:"adiga",host:"beetle", description:"test",type:"dev",updatedate:"fri apr 27 07:21:43 ist 2012"},                 {cfgid:2, name:"max miller",host:"barry", description:"test",type:"dev",updatedate:"mon apr 16 04:11:40 ist 2012"}                 ]; 

this code

jquery.fn.abcgrid = function (tableid, heading, data, options) {     abcoptions = jquery.extend ({     tablecss: "tableforms",     tableheadercss: "tableheading",     label: "informatica csm",     header: heading,     rows: data     }, options);      var ele_table='';     var ele_table_start='<table id="'+abcoptions.tableid+'" class="'+abcoptions.tablecss+'"><tbody>';     var ele_table_end='</tbody></table>';     var ele_table_header='';     var ele_table_row='';      var tempheader='';     var temprow='';      /*table header creation*/     for(var i=0;i<abcoptions.header.length;i++)         tempheader+='<td class="'+abcoptions.tableheadercss+'">'+abcoptions.header[i]+'</th>';     ele_table_header='<tr>'+tempheader+'</tr>';      ele_table=ele_table_start+ele_table_header+ele_table_end;     $(this).html(ele_table);     //it creates headers }; 

i call code

$('#updatediv').abcgrid("tabel1", headers, myrows); 

to value of item in map, do:

abcoptions.rows[i].cfgid 

the rows[i] map -- can place key after dot, or rows[i]['cfgid']

-- edit: renamed header rows.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -