Refreshing gridx cell value using DateTextBox

350 views Asked by At

Working with gridx. I've added a Diji/form/DateTextBox to one of the columns.

I am able to save back to the grid's JSON, but I am not managing to update what is displayed in the cell.

function deadlineDecorator(value) {
    return '<div data-dojo-type="dijit/form/DateTextBox" data-dojo-props="constraints:{datePattern: \'dd/MM/yyyy\'}" data-dojo-attach-point="deadlineCal" required="true" />';
}

function <portlet:namespace/>deadlineCellValueSet(gridData, storeData, cellWidget) {    

    cellWidget.deadlineCal.set('value', newDate(gridData)); 
    cellWidget.deadlineCal.constraints.min = new Date();
}

var locale = dojo.require("dojo.date.locale");

function getDate(d){
    res = locale.format(d, {
        selector: 'date',
        datePattern: 'dd/MM/yyyy'
    });
    return res;
}

function deadlineChange(cellWidget, cell) {
    return [
        [cellWidget.deadlineCal, 'onChange', function(e){                                            
            cell.setRawData(getDate(cellWidget.deadlineCal.value));             
        }]
    ];
}

I am creating the grid using this:

data = [{"id": 1, "dead": 18/12/2014}];

function creategrid() {
    var gridData = {data: data};
    var dataStore = new dojo.store.Memory(gridData);
    grid.setStore(datastore);


};

How can I save the chosen date back to the JSON AND show that change in the cell.

I guess I could refresh the whole grid, but that doesn't seem like a very elegant solution?

0

There are 0 answers