jQWidgets Forums

jQuery UI Widgets Forums Grid Adding a bland row and editing a cell

This topic contains 3 replies, has 2 voices, and was last updated by  Dimitar 10 years, 6 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Adding a bland row and editing a cell #63206

    fletcherrl
    Participant

    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.”);
    }
    });

    Adding a bland row and editing a cell #63207

    Dimitar
    Participant

    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,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Adding a bland row and editing a cell #63209

    fletcherrl
    Participant

    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}
    ]
    });

    Adding a bland row and editing a cell #63244

    Dimitar
    Participant

    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,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.