jQWidgets Forums

jQuery UI Widgets Forums Grid help with getcellvalue and getcelltext

This topic contains 4 replies, has 3 voices, and was last updated by  Peter Stoev 9 years, 5 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • help with getcellvalue and getcelltext #19951

    stevewp
    Participant

    I am missing something. I cannot get anything other than ‘null’ when trying to retrieve cell text.

    Can someone explain to me what I am doing wrong?

    Here is the event handler for ‘rowselect’

    $(“#jqxgrid”).on(‘rowselect’, function (event) {
    $(“#editButton”).jqxButton({disabled: false});
    $(“#removeButton”).jqxButton({disabled: false});

    var args = event.args;
    var row = args.rowindex;
    alert(row);
    // SHOWS THE CORRECT INTEGER HERE
    var value = $(‘#jqxGrid’).jqxGrid(‘getcellvalue’, row, “UniqueID”);
    alert(value);
    // SHOWS NULL HERE
    var text = $(‘#jqxGrid’).jqxGrid(‘getcelltext’, row, “UniqueID”);
    alert(text);
    // SHOWS NULL HERE
    });

    Here is how I setup the grid:

    $(“#jqxgrid”).jqxGrid(
    {
    width: ‘100%’,
    height: ‘100%’,
    source: dataAdapter,
    showfilterrow: true,
    filterable: true,
    theme: ‘darkblue’,
    columns: [
    { text: ‘UniqueID’, datafield: ‘UniqueID’, width: 150, cellsalign: ‘left’},
    { text: ‘Decedent L Name’, datafield: ‘DecedentLastName’, width: 150, cellsalign: ‘left’},
    { text: ‘Decedent F Name’, datafield: ‘DecedentFirstName’, width: 150, cellsalign: ‘left’ },
    { text: ‘Dt of Death’, datafield: ‘DateofDeath’, width: 100,
    cellsformat: ‘d’, cellsalign: ‘left’ },
    { text: ‘Dt of Birth’, datafield: ‘DateofBirth’, width: 100,
    cellsformat: ‘d’, cellsalign: ‘left’ },
    { text: ‘Purch L Name’, datafield: ‘PurchaserLastName’, width: 150 },
    { text: ‘Purch F Name’, datafield: ‘PurchaserFirstName’, width: 150 },
    { text: ‘Section’, datafield: ‘Section’, width: 50 },
    { text: ‘Block’, datafield: ‘Block’, width: 50 },
    { text: ‘Lot’, datafield: ‘Lot’, width: 50 },
    { text: ‘Space’, datafield: ‘Space’, width: 50 }

    ],
    pager: function (pagenum, pagesize, oldpagenum)
    {
    // callback called when a page or page size is changed.
    }
    });


    Peter Stoev
    Keymaster

    Hi,

    Your grid’s ID in the posted code is “jqxgrid”. However, you try to call methods of object with ID = “jqxGrid”.

    Best Regards,
    Peter Stoev

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

    help with getcellvalue and getcelltext #80799

    Steve
    Participant

    I am having the same problem. My code is below. In the code I update div called log. Here is what displays A cell has been selected: null, null. I also put a bunch console.log statements in the javascript. Here is what gets displayed in the console.

    args: [object Object]
    column: Contact
    dataField: league-contact
    rowBoundIndex: 27
    value: null
    displayValue: null

    I checked the grid id and it is jqxgrid in all cases. I’m stumped.

    var source = {
    datatype: “json”,
    datafields: [{ name: ‘league_name’, type: ‘string’ },
    { name: ‘curling_day’, type: ‘string’ },
    { name: ‘league-contact’, type: ‘string’ },
    { name: ‘contact_email’, type: ’email’ },
    { name: ‘contact_phone’, type: ‘phone’}],
    id: ‘UID’,
    url: ‘Services/GetLeague.cshtml/’,
    async: true
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    $(“#jqxgrid”).jqxGrid({
    width: ‘100%’,
    autoheight: true,
    altrows: true,
    source: dataAdapter,
    selectionmode: ‘singlecell’,
    columns: [{ text: ‘League’, datafield: ‘league_name’, width: ‘20%’ },
    { text: ‘Day’, datafield: ‘curling_day’, width: ‘20%’ },
    { text: ‘Contact’, datafield: ‘league-contact’, width: ‘20%’ },
    { text: ’email’, datafield: ‘contact_email’, width: ‘20%’ },
    { text: ‘Phone’, datafield: ‘contact_phone’, width: ‘20%’}]
    });
    $(“#jqxgrid”).on(‘cellselect’, function (event) {
    // event arguments.
    var args = event.args;
    console.info(“args: ” + args);
    // get the column’s text.
    var column = $(“#jqxgrid”).jqxGrid(‘getcolumn’, event.args.datafield).text;
    console.info(“column: ” + column);
    // column data field.
    var dataField = event.args.datafield;
    console.info(“dataField: ” + dataField);
    // row’s bound index.
    var rowBoundIndex = event.args.rowindex;
    console.info(“rowBoundIndex: ” + rowBoundIndex);
    // cell value
    var value = $(“#jqxgrid”).jqxGrid(‘getcellvalue’, event.args.rowindex, column.datafield);
    console.info(“value: ” + value);
    var displayValue = $(“#jqxgrid”).jqxGrid(‘getcelltext’, event.args.rowindex, column.displayfield);
    console.info(“displayValue: ” + displayValue);
    $(“#log”).html(“A cell has been selected: ” + value + “, ” + displayValue);

    });

    help with getcellvalue and getcelltext #80803

    Steve
    Participant

    I figured it out. I get the rowid from
    Get the rowindex using var rowBoundIndex = event.args.rowindex;. Get the data field using var dataField = event.args.datafield; Get the cell value using var value = $(“#jqxgrid”).jqxGrid(‘getcellvalue’, rowBoundIndex, dataField); or var displayValue = $(“#jqxgrid”).jqxGrid(‘getcelltext’, rowBoundIndex, dataField);.

    The code is below.

    $(“#jqxgrid”).on(‘cellclick’, function (event) {

    // event arguments.
    var args = event.args;
    console.info(“args: ” + args);
    // get the column’s text.
    var column = $(“#jqxgrid”).jqxGrid(‘getcolumn’, event.args.datafield).text;
    console.info(“column: ” + column);
    // column data field.
    var dataField = event.args.datafield;
    console.info(“dataField: ” + dataField);
    // row’s bound index.
    var rowBoundIndex = event.args.rowindex;
    console.info(“rowBoundIndex: ” + rowBoundIndex);
    // cell value
    var value = $(“#jqxgrid”).jqxGrid(‘getcellvalue’, rowBoundIndex, dataField);
    console.info(“value: ” + value);
    var displayValue = $(“#jqxgrid”).jqxGrid(‘getcelltext’, rowBoundIndex, dataField);
    console.info(“displayValue: ” + displayValue);
    $(“#log”).html(“A cell has been selected: ” + value + “, ” + displayValue);

    });

    help with getcellvalue and getcelltext #80807

    Peter Stoev
    Keymaster

    Hi Steve,

    The first code would work, too if instead of var column = $(“#jqxgrid”).jqxGrid(‘getcolumn’, event.args.datafield).text; you wrote var column = $(“#jqxgrid”).jqxGrid(‘getcolumn’, event.args.datafield);

    Best Regards,
    Peter Stoev

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

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

You must be logged in to reply to this topic.