如何手动加载jqgrid中的数据? [英] How to load data in jqgrid manually?

查看:251
本文介绍了如何手动加载jqgrid中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何做到这一点?



我想将数据形式的组合框和文本框数据加载到网格中。 >



上图:select

这是我的Jsp Grid代码:

 < s:url id =remoteurlaction =/> 
< sjg:grid caption =RECORDS
gridModel =dto_plot_rep
width =300height =80
href =%{remoteurl}
id =gridtable2
rownumbers =true
viewrecords =true
pager =true
pagerPosition =centar
navigator = true
navigatorSearch =true
navigatorSearchOptions ={multipleSearch:true}
navigatorDelete =false
navigatorEdit =false
loadonce = true
onCompleteTopics =cal_tot
userDataOnFooter =true
reloadTopics =oadPlot
rowNum =10
>

< sjg:gridColumn name =m_tab_pindex =m_tab_ptitle =Pwidth =180align =leftsearch =truesearchoptions ={sopt:[ 'eq','cn']}sortable =true/>
< sjg:gridColumn name =m_tab_ceindex =m_tab_ctitle =Cwidth =180align =leftsearch =truesearchoptions ={sopt:['eq', 'cn']}sortable =true/>

< / sjg:grid>


解决方案

addRowData 方法可让您将行添加到您的jqgrid中。



假设您可以将表单中的数据捕获到数组中 arr = [2,4.0]
您可以按如下所示插入行:

 < button id =addtype =button> ADD< / button> 

< script>
$(#add)。click(function(){
arr = [2,4.0]; //你将需要根据你的表单的值填充这个数组
lastId ='parseInt($(#gridId).getDataIDs()。length)+ 1;
$(#gridId)。jqGrid('addRowData',lastId,arr,last);
} );
< / script>


I want to load data form combobox and textfield data to grid.

How to do it?

Above Image : select box data in column 1 and textbox data in column 2.

Here is my Jsp Grid code:

<s:url id="remoteurl" action="" />
        <sjg:grid caption="RECORDS"
        gridModel="dto_plot_rep" 
        width="300" height="80"
        href="%{remoteurl}"    
        id="gridtable2" 
        rownumbers="true"
        viewrecords="true"
        pager="true"    
        pagerPosition="centar"
        navigator="true"
        navigatorSearch="true"
        navigatorSearchOptions="{multipleSearch:true}"
        navigatorDelete="false"  
        navigatorEdit="false"    
        loadonce="true"         
        onCompleteTopics="cal_tot" 
        userDataOnFooter="true"
        reloadTopics="reloadPlot"
        rowNum="10" 
       >

        <sjg:gridColumn name="m_tab_p" index="m_tab_p" title="P"  width="180" align="left" search="true" searchoptions="{sopt:['eq','cn']}" sortable="true"/>
        <sjg:gridColumn name="m_tab_ce" index="m_tab_c" title="C"  width="180" align="left" search="true" searchoptions="{sopt:['eq','cn']}" sortable="true"/>

        </sjg:grid>

解决方案

The addRowData method lets you add rows in to your jqgrid. Docs.

Let's say you can capture the data from your form in to an array arr = [2, 4.0] You can insert the row as follows:

<button id="add" type="button">ADD</button>

<script>
$("#add").click(function(){
    arr = [2, 4.0]; //You will need to populate this array based on values of your form
    lastId = parseInt($(#gridId).getDataIDs().length) + 1;
    $("#gridId").jqGrid('addRowData',lastId, arr, "last");
  });
</script>

这篇关于如何手动加载jqgrid中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆