jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Get Original Value of Cell
Tagged: cell value, original value
This topic contains 4 replies, has 2 voices, and was last updated by Rodolfo Hill 7 years, 10 months ago.
-
Author
-
I try to get the original value of the grid cell, not the value displayed.
When I try to get the value of the cell, returns the label, not the value. Not return the real value came from Source / Adapter.var standardTypeSource =
{
datatype: “json”,
datafields: [
// name – determines the field’s name.
// value – the field’s value in the data source.
// values – specifies the field’s values.
// values.source – specifies the foreign source. The expected value is an array.
// values.value – specifies the field’s value in the foreign source.
// values.name – specifies the field’s name in the foreign source.
// When the adapter is loaded, each record will have a field called “Country”. The “Country” for each record comes from the countriesAdapter where the record’s “countryCode” from gridAdapter matches to the “value” from countriesAdapter.
{ name: ‘standardTypeId’, type: ‘number’ },
{ name: ‘name’, type: ‘string’ }
],
id: ‘standardTypeId’,
url: “/getStandardType”,
type: “GET”,
async: false
}var standardTypeAdapter = new $.jqx.dataAdapter(standardTypeSource, { autoBind: true });
var standardSource =
{
datatype: “json”,
datafields: [
// name – determines the field’s name.
// value – the field’s value in the data source.
// values – specifies the field’s values.
// values.source – specifies the foreign source. The expected value is an array.
// values.value – specifies the field’s value in the foreign source.
// values.name – specifies the field’s name in the foreign source.
// When the adapter is loaded, each record will have a field called “Country”. The “Country” for each record comes from the countriesAdapter where the record’s “countryCode” from gridAdapter matches to the “value” from countriesAdapter.
{ name: ‘standardId’, type:’number’ },
{ name: ‘standardTypeId’, type:’number’, values: { source: standardTypeAdapter.records, value: ‘standardTypeId’, name: ‘name’ }},
{ name: ‘enterpriseId’, type:’number’ },
{ name: ‘name’, type: ‘string’ },
{ name: ‘main’, type: ‘string’ },
{ name: ‘description’, type: ‘string’ },
{ name: ‘version’, type: ‘string’ },
{ name: ‘issueDate’, type: ‘string’ },
{ name: ‘dueDate’, type: ‘string’ }
],
id: ‘standardId’,
url: “/bringStandardRows”,
root: ‘rows’,
type: “GET”,
async: false,
addrow: function (rowid, rowdata, position, commit) {
// synchronize with the server – send insert command
// call commit with parameter true if the synchronization with the server is successful
//and with parameter false if the synchronization failed.
// you can pass additional argument to the commit callback which represents the new ID if it is generated from a DB.
commit(true);
},
deleterow: function (rowid, commit) {
// synchronize with the server – send delete command
// call commit with parameter true if the synchronization with the server is successful
//and with parameter false if the synchronization failed.
commit(true);
},
updaterow: function (rowid, newdata, commit) {
// synchronize with the server – send update command
// call commit with parameter true if the synchronization with the server is successful
// and with parameter false if the synchronization failed.
commit(true);
},
beforeprocessing: function(data)
{
standardSource.totalrecords = data[0].totalRows;
},
pager: function (pagenum, pagesize, oldpagenum) {
// callback called when a page or page size is changed.
//alert(“hubo movimiento en el pager”);
}
}var standardAdapter = new $.jqx.dataAdapter(standardSource, { autoBind: true });
I also analized all the elements of the dataRecord, and do not appear the original value, appear the displayed value (label).
//var selectedrowindex = $(“#jqxgrid”).jqxGrid(‘getselectedrowindex’);
var rowindex = $(“#standardGrid”).jqxGrid(‘getselectedrowindex’);
var rowid = $(“#standardGrid”).jqxGrid(‘getrowid’, rowindex);editrow = rowindex;
var offset = $(“#standardGrid”).offset();
alert(“offset = ” + offset);var dataRecord = $(“#standardGrid”).jqxGrid(‘getrowdata’, editrow);
var out = ”;
for (var p in dataRecord) {
out += p + ‘: ‘ + dataRecord[p] + ‘\n’;
}
console.log(“dataRecord = ” + out);console.log(“Con rowindex = ” + rowindex);
var valueFromGetCellValue = $(‘#standardGrid’).jqxGrid(‘getcellvalue’, rowindex, “standardTypeId”);
var valueFromGetCellText = $(‘#standardGrid’).jqxGrid(‘getcelltext’, rowindex, “standardTypeId”);
console.log(“valueFromGetCellValue = ” + valueFromGetCellValue);
console.log(“valueFromGetCellText = ” + valueFromGetCellText);//var Value = $(‘#jqxgrid’).jqxGrid(‘getcellvalue’, row, ‘ID’);
console.log(“Con rowid = ” + rowid);
var valueFromGetCellValueById = $(‘#standardGrid’).jqxGrid(‘getcellvaluebyid’, rowid, “standardTypeId”);
var valueFromGetCellTextById = $(‘#standardGrid’).jqxGrid(‘getcelltextbyid’, rowid, “standardTypeId”);
console.log(“valueFromGetCellValueById = ” + valueFromGetCellValueById);
console.log(“valueFromGetCellTextById = ” + valueFromGetCellTextById);allways appear:
dataRecord = standardId: 6
standardTypeId: Caracteristica
enterpriseId: 0
name: Disuadir el acceso furtivo.
main: A.1.3.
description:
version: 1.0.0
issueDate: 2017-07-11
dueDate: 2017-07-11
uid: 6
boundindex: 6
uniqueid: 2117-16-24-31-162225
visibleindex: 6Con rowindex = 6
valueFromGetCellValue = Caracteristica
valueFromGetCellText = Caracteristica
Con rowid = 6
valueFromGetCellValueById = Caracteristica
valueFromGetCellTextById = CaracteristicaNever appear the value of standardTypeId
Hello Rodolfo Hill,
You can use our API
getcell
, with it you can get the element as an object using:console.dir(cell)
.
There you can see the value. After that, you can easily access it withconsole.log(cell.value);
.Best Regards,
StanislavjQWidgets Team
http://www.jqwidgets.com/I have a column defined with values, like:
{ name: ‘standardTypeId’, type:’number’, values: { source: standardTypeAdapter.records, value: ‘standardTypeId’, name: ‘name’ }},
If I, use:
var value = $(‘#standardGrid’).jqxGrid(‘getcellvalue’, rowindex, “standardTypeId”);
Always return me always return to me the name and not the real value
I use jqwidgets.4.2.1 and jquery-3.2.1, but with jqwidgets.4.5.0 and jqwidgets.4.5.4 I had the same result.
I change the jqwidgets version to jqwidgets.4.5.4 because the version jqwidgets.4.2.1 does not have tabs on popup windows.
It continue without running.
Please Help Me
-
AuthorPosts
You must be logged in to reply to this topic.