jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Adding a bland row and editing a cell
Tagged: addrow, begincelledit, endcelledit, grid, jqxgrid, setcellvalue
This topic contains 3 replies, has 2 voices, and was last updated by Dimitar 10 years, 6 months ago.
-
Author
-
I apologize if this has been answered before…
This is not working for me… what am I doing wrong.
The row gets added to the grid, but the selected destination does not get entered into the cell.
Thanks in advance$(“#addOutsideDestination”).click(function () {
var myDestinationValue = document.getElementById(‘destinationCityPickMe’).value;
var myDestinationLength = myDestinationValue.length;if (myDestinationLength > 0){
$(“#newDestinationsGrid”).jqxGrid(“addrow”, null, {}, “first”);
$(“#newDestinationsGrid”).jqxGrid(“selectrow”, 0);
$(“#newDestinationsGrid”).jqxGrid(“begincelledit”, 0, ‘tnrdDescription’);
$(“#newDestinationsGrid”).jqxGrid(“setcellvalue”, 0, ‘tnrdDescription’, myDestinationValue);
$(“#newDestinationsGrid”).jqxGrid(“endcelledit”, 0, ‘tnrdDescription’, false);
} else {
alert(“Please enter or select a destination.”);
}
});Hello fletcherrl,
You should not call begincelledit and endcelledit. You only need:
$("#newDestinationsGrid").jqxGrid("addrow", null, {}, "first"); $("#newDestinationsGrid").jqxGrid("selectrow", 0); $("#newDestinationsGrid").jqxGrid("setcellvalue", 0, 'tnrdDescription', myDestinationValue);
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Thank you for your prompt response.
I originally tried it without the begincelledt and endcelledit and only added those two calls after it didn’t work.
The values still do not appear in the grid cell.
Do I have to do a refresh or something?Here’s my grid code…
var source =
{
datatype: ‘json’,
datafields:[
{name:’tnrdTrId’, type: ‘int’},
{name:’tnrdRegion’, type: ‘int’},
{name:’tnrdGovernorate’, type: ‘int’},
{name:’tnrdCity’, type: ‘int’},
{name:’tnrdAreaOfConcern’, type: ‘int’},
{name:’tnrdDescription’, type: ‘string’}
]
};var dataAdapter = new $.jqx.dataAdapter(source);
$(‘#newDestinationsGrid’).jqxGrid(
{
width: 900,
height: 300,
source: dataAdapter,
enabletooltips: true,
editable: true,
columns:[
{text: ‘TravRecId’, datafield:’tnrdTrId’, hidden: true},
{text: ‘Region’, datafield:’tnrdRegion’, hidden: true},
{text: ‘Gov’, datafield:’tnrdGovernorate’, hidden: true},
{text: ‘City’, datafield:’tnrdCity’, hidden: true},
{text: ‘AOC’, datafield:’tnrdAreaOfConcern’, hidden: true},
{text: ‘Description’, datafield:’tnrdDescription’, width:875}
]
});Hi fletcherrl,
Everything seems in order. You do not need to refresh the grid after calling setcellvalue. Here is an example that shows how to set the value of a cell from a newly added first row: http://jsfiddle.net/Dimitar_jQWidgets/68e8txLy/. Maybe the variable myDestinationValue is not set correctly in your case?
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.