How to load data in jqgrid manually?

2019-07-06 20:02发布

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

How to do it?

enter image description here

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>

1条回答
闹够了就滚
2楼-- · 2019-07-06 20:23

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>
查看更多
登录 后发表回答