Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #100579
    admin
    Keymaster

    <div class=”bbp-reply-content”>
    hi,
    can you help me use onCellUpdate with grid? where can I to find the example?
    Fabio
    </div>

    #100583
    admin
    Keymaster

    Hi Fabio,
    Please, refer below to a sample implementation of the onCellUpdate callback function. It provides information about old and new cell value, the cell that is edited and also a confirm callback function which you may use to cancel the changes. In the example, when “test” is entered, the value is not saved, otherwise it is saved after editing.

    Smart('#grid', class {
    get properties() {
    return {
    onCellUpdate: function(cell, oldValue, newValue, confirm) {
    oldValue = cell.value;
    alert(cell.row.id + "/" + cell.column.dataField);
    if (newValue === "test") {
    confirm(false);
    }
    else {
    confirm(true);
    }
    },
    dataSource: new Smart.DataAdapter(
    {
    dataSource: generateData(1000),
    dataFields:
    [
    'id: number',
    'firstName: string',
    'lastName: string',
    'productName: string',
    'available: bool',
    'quantity: number',
    'price: number',
    'total: number'
    ]
    }),
    editing: {
    enabled: true,
    mode: 'cell'
    },
    columns: [
    {
    label: 'First Name', dataField: 'firstName'
    },
    { label: 'Last Name', dataField: 'lastName' },
    { label: 'Product', dataField: 'productName' },
    { label: 'Available', dataField: 'available', template: 'checkBox', editor: 'checkBox' },
    { label: 'Quantity', dataField: 'quantity', editor: 'numberInput' },
    { label: 'Unit Price', dataField: 'price', editor: 'numberInput', cellsFormat: 'c2' }
    ]
    }
    }
    });

    Hope this helps.
    Regards,
    Peter

    #100584
    admin
    Keymaster

    Thank you very much

    #102720
    James
    Participant

    Hi,

    Please where do I find a similar implementation in Angular?

    #102728
    admin
    Keymaster

    Hi James,

    onCellUpdate is a property so in angular in app.component.ts it would be:

    ` onCellUpdate = function(cell, oldValue, newValue, confirm) {
    oldValue = cell.value;
    alert(cell.row.id + “/” + cell.column.dataField);
    if (newValue === “test”) {
    confirm(false);
    }
    else {
    confirm(true);
    }
    }`

    in the template, you will need to set the onCellUpdate grid property to point to the property in the app.component.ts.

    Best regards,
    Peter Stoev

    Smart UI Team
    https://www.htmlelements.com/

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.