如何在jsp中没有选择的情况下获取jqgrid第一行数据? [英] how to get jqgrid first row data with out select in jsp?

查看:66
本文介绍了如何在jsp中没有选择的情况下获取jqgrid第一行数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在jqgrid中获取表的第一行数据?

How to get table first row data in jqgrid?

我想从jqgrid获得2和4.0的数据,如何在不单击表值的情况下获取此值?

Here I want 2 and 4.0 data from jqgrid how to get this value without click table value?

var rowId = $("#gridtable2").getRowData(0);
var name = rowId['m_tab_p'];

gridtable2是jqgrid id,m_tab_p是第一列ID.

Here gridtable2 is jqgrid id, and m_tab_p is 1st column id..

JSP网格代码:

<s:url id="remoteurl2" action="add_act" />
                        <sjg:grid caption="RECORDS" gridModel="dto_plot_rep" width="250"
                            height="70" href="%{remoteurl2}" 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"
                             rowNum="0">

                            <sjg:gridColumn name="m_tab_p" index="m_tab_plotno"
                                title="PLOT" width="180" align="left" search="true"
                                searchoptions="{sopt:['eq','cn']}" sortable="true" />
                            <sjg:gridColumn name="m_tab_c" index="m_tab_cent" title="CENT"
                                width="180" align="left" search="true"
                                searchoptions="{sopt:['eq','cn']}" sortable="true" />
                        </sjg:grid> 

推荐答案

要获取第一行的数据,可以在loadComplete

To get the data of first row you can use following in loadComplete

        //Call On JqGrid Load Complete
        loadComplete:function(data){
                    //id list value
                    var ids = $("#gridtable2").jqGrid('getDataIDs');
                    //get first id
                    var cl = ids[0];
                    var rowData = $(this).getRowData(cl); 
                    var temp= rowData['UserId']
            },

如果在loadComplete之外使用它,请使用:

And if you are using it outside of loadComplete use :

  var ids = $("#gridtable2").jqGrid('getDataIDs');
                //get first id
 var cl = ids[0];
    //fetch row data 
 var rowData = $("#gridtable2").getRowData(cl); 
    //fetch individual cell value
 var celValue = $("#gridtable2").jqGrid ('getCell', cl, 'UserId');

这是有效的 JSFIDDLE

这篇关于如何在jsp中没有选择的情况下获取jqgrid第一行数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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