Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get row id of selected row in jqgrid

Tags:

jquery

jqgrid

I am writing this code and calling the method on rowdoubleclick of the jqgrid. I have also given all the tags and the column names of my jqgrid. Can you help me figure out why I am getting "undefined" when I alert the values?

<cc1:JQGrid ID="grdUserDetails" runat="server" Width="770px" Height="350px" ClientSideEvents-RowDoubleClick="ForwardDetails">
                <Columns>
                    <cc1:JQGridColumn DataField="VisitorID" HeaderText="ID" TextAlign="Left" PrimaryKey="true"
                        Visible="false" Searchable="false">
                    </cc1:JQGridColumn>
                    <cc1:JQGridColumn DataField="PersonName" HeaderText="Visitor" TextAlign="Left">
                    </cc1:JQGridColumn>
                    <cc1:JQGridColumn DataField="CompanyName" HeaderText="Company Name" TextAlign="Left">
                    </cc1:JQGridColumn>
                    <cc1:JQGridColumn DataField="ContactNumber" HeaderText="Contact Number" TextAlign="Left">
                    </cc1:JQGridColumn>
                    <cc1:JQGridColumn DataField="Address" HeaderText="Address" TextAlign="Left">
                    </cc1:JQGridColumn>
                    <cc1:JQGridColumn DataField="Email" HeaderText="Email" TextAlign="Left">
                    </cc1:JQGridColumn>
                    <cc1:JQGridColumn DataField="DisplayDate" HeaderText="Last Visited on" TextAlign="Left">
                    </cc1:JQGridColumn>
                </Columns>
                <PagerSettings PageSize="15" PageSizeOptions="[15,25,50]" />
                <ToolBarSettings ShowSearchButton="false" ShowRefreshButton="true" ShowSearchToolBar="true">
                </ToolBarSettings>
                <AppearanceSettings ShowRowNumbers="true" ></AppearanceSettings>
                <SearchToolBarSettings SearchToolBarAction="SearchOnKeyPress" />
            </cc1:JQGrid>

 function ForwardDetails() {
        var PersonName, Address, CompanyName, ContactNumber, Email;
        var selectedRowId, cellValue;
        var myGrid = $('#grdUserDetails');
         selectedRowId = myGrid.jqGrid('getGridParam', 'selrow');
         cellValue = myGrid.jqGrid('getCell', selectedRowId, 'Visitor Name');
        window.opener.setValues(PersonName, Address, CompanyName, ContactNumber, Email);
        window.close();           
    }
like image 883
Vishweshwar Kapse Avatar asked Mar 11 '13 13:03

Vishweshwar Kapse


People also ask

How to input rowid information in jqgrid?

Thus the input data of jqGrid have tocontains rowid information. There are many alternative formats for the input data of jqGrid. In the most common way, the input data should contain idproperty. If your input data uses ProductIDas the unique id of the row, then you can add the option jsonReader: { id: "ProductID" }to inform jqGrid about that.

How to add productid as a column in jqgrid?

If your input data uses ProductIDas the unique id of the row, then you can add the option jsonReader: { id: "ProductID" }to inform jqGrid about that. In the case you will don't need to include ProductIDas the column in colModel.

What is rowdata in JavaScript?

What is rowData - javaScript object (array) or document object. If it is document object then the id is RowData.id, if this is JavaScript object you should know which field is the id, then the id will be RowData.ProductID or RowData['ProductID'] – Tony Tomov

How do I find the ID of a rowdata object?

If it is document object then the id is RowData.id, if this is JavaScript object you should know which field is the id, then the id will be RowData.ProductID or RowData['ProductID'] – Tony Tomov Aug 2 '17 at 9:22


1 Answers

try this:

var myGrid = $('#list'),
selectedRowId = myGrid.jqGrid ('getGridParam', 'selrow'),
cellValue = myGrid.jqGrid ('getCell', selectedRowId, 'columnName');

where columnName is the column you provided in the name property of colModel

and #list is the id of your grid.

ref1 , ref2

like image 194
Manish Mishra Avatar answered Oct 08 '22 04:10

Manish Mishra