jQWidgets Forums

jQuery UI Widgets Forums Grid Dynamic cell editing for one cell

This topic contains 3 replies, has 2 voices, and was last updated by  Peter Stoev 12 years, 8 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Dynamic cell editing for one cell #8659

    DavidSimmons
    Participant

    Using cell editing is there a way to dynamically determine the datafield and value of the edited field so you do not have to update each column?

    $(document).ready(function () {
    var theme = getTheme();

    var source =
    {
    datatype: “json”,
    datafields: [
    { name: ‘CompanyName’ },
    { name: ‘ContactName’ },
    { name: ‘ContactTitle’ },
    { name: ‘Address’ },
    { name: ‘City’ },
    { name: ‘Country’ }
    ],
    url: ‘data.php’,
    root: ‘Rows’,
    beforeprocessing: function (data) {
    source.totalrecords = data[0].TotalRows;
    },
    sort: function () {
    $(“#jqxgrid”).jqxGrid(‘updatebounddata’);
    },
    updaterow: function (rowid, rowdata) {

    alert(“datafield=value”); **************

    /*
    // synchronize with the server – send update command
    var data = “update=true&FirstName=” + rowdata.FirstName + “&LastName=” + rowdata.LastName + “&Title=” + rowdata.Title;
    data = data + “&Address=” + rowdata.Address + “&City=” + rowdata.City + “&Country=” + rowdata.Country + “&Notes=””;
    data = data + “&EmployeeID=” + rowdata.EmployeeID;
    $.ajax({
    dataType: ‘json’,
    url: ‘data.php’,
    data: data,
    success: function (data, status, xhr) {
    // update command is executed.
    }
    });*/
    }
    };
    var dataAdapter = new $.jqx.dataAdapter(source);

    $(“#jqxgrid”).jqxGrid(
    {
    width: 1000,
    source: dataAdapter,
    theme: theme,
    sortable: true,
    sorttogglestates: 1,
    autoheight: true,
    pageable: true,
    columnsresize: true,
    editable: true,
    rendergridrows: function () {
    return dataadapter.records;
    },
    columns: [
    { text: ‘Company Name’, datafield: ‘CompanyName’, width: 250 },
    { text: ‘Contact Name’, datafield: ‘ContactName’, width: 150 },
    { text: ‘Contact Title’, datafield: ‘ContactTitle’, width: 180 },
    { text: ‘City’, datafield: ‘City’, width: 120 },
    { text: ‘Country’, datafield: ‘Country’, width: 120 }
    ]
    });
    });

    Dynamic cell editing for one cell #8660

    Peter Stoev
    Keymaster

    Hi David,

    The cellvaluechanged event is triggered when the value of a cell is changed. It provides information about the changed cell, too.
    For more information about the event: jquery-grid-api.htm.

    Best Regards,
    Peter SToev

    jQWidgets Team
    http://www.jqwidgets.com

    Dynamic cell editing for one cell #8665

    DavidSimmons
    Participant

    Is there a working example using the cellvaluechanged I can look at?

    Dynamic cell editing for one cell #8666

    Peter Stoev
    Keymaster

    Hi David,

    We don’t have a sample with cellvaluechanged. The API documentation shows how to subscribe to the event and what parameters are passed to the callback function. The parameters(rowindex, datafield and new cell value) should be enough as information to send an update to your server.

    Best Regards,
    Peter SToev

    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.