ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: ncpowerbrute66 on November 23, 2015, 12:35:20 pm
-
I can load grids fine using c# mvc but when I use the calls to getData, getRowData etc... I can't get an array as the documentation suggests. I create my grids like this:
var colModel = [
{
title: "Name", //title of column.
width: 65, //initial width of column
editable: false,
dataType: "string", //data type of column
dataIndx: "REP_NAME" //should match one of the keys in row data.
}
var dataModelTop = {
location: "remote",
sorting: "local",
sortIndx: "CHARGE_TYPE_DESC",
sortDir: "up",
dataType: "JSON",
method: "GET",
getUrl: function () {
return { url: Url4controller };
},
getData: function (response) {
return { data: response };
}
}
var grid_Top = pq.grid("#grid_Top", objTop);
var totalRecordsTop = $("#grid_Top").pqGrid('option', 'dataModel.data').length; //this works
//I want to access the first row of a column named Name of a refreshed grid to populate eleswhere on my webpage
var datafrmgrid = $("#grid_Top").pqGrid( "getCell", { rowIndx: 0, dataIndx: "Name" } ); //does not work.
Please help
-
getRowData is the method to get data for a row.
var rowData = $("#grid_Top").pqGrid( "getRowData", { rowIndx: 0 } );
Further to get cell value of field with dataIndx: "REP_NAME"
var cellData = rowData.REP_NAME
-
That makes sense. I see where I was using the column name Name and not the dataIndex: REP_NAME. But when I add the below lines I still can't access the value of a cell.
var repname = $("#grid_Top").pqGrid("getCell", { rowIndx: 0, dataIndx: "REP_NAME" });
alert("rename="+repname); // this gives me an alert box message repname=[object Object]
var rowData = $("#grid_Top").pqGrid("getRowData", { rowIndx: 0 });
var cellData = rowData.REP_NAME;
alert("cellData=", cellData); //this gives me an alert box message cellData=
I have attached my cshtml file.
-
I got it to work. Thanks for your help
//SOLUTION
var row1Data = $("#grid_Top").pqGrid("getRowData", { rowIndx: 0 });
var repname = row1Data.REP_NAME;
$("#reptop").text(repname);