将数据从数据库中提取到jquery网格中

时间:2013-08-02 07:34:12

标签: jquery jquery-ui

<table id="grid"></table>

<script>
                            $("#grid").jqGrid({
                                datatype:"local",
                                height:250,
                                colNames:['ROLL','FIRST_NAME','LAST_NAME','DATE OF BIRTH','CLASS'],
                                colModel:[{name:'id',index:'id', width:70, sorttype:"int"}, 
                                        {name:'fname',index:'fname', width:120},
                                        {name:'lname',index:'lname', width:120},
                                        {name:'dob',index:'dob', width:160, align:"right"}, 
                                        {name:'clas',index:'clas', width:90, align:"right"}],
                                        caption:"LIST OF STUDENTS",
                                        multiselect:true,
                            });

                            var mydata = [ {id:"1",fname:"abc",lname:"dfg",dob:"11-10-1991",clas:"second"},
                                            {id:"2",fname:"xyz",lname:"dfg",dob:"11-10-1991",clas:"second"}];

                            for(var i=0;i<=mydata.length;i++) 
                                    jQuery("#grid").jqGrid('addRowData',i+1,mydata[i]);

                        </script>

我想从数据库中获取数据并使网格表动态化。

即。如何动态地向jquery网格添加数据?

我该怎么做?

0 个答案:

没有答案