Bugs

Developer
Apr 28, 2011 at 6:00 AM
Edited Apr 28, 2011 at 6:14 AM

1) There's a bug in mvc.controls.manager.js that's fired whenever you try to save in the demo application. The bug is that _onAfterGridSave refers to gridName when it should refer to clientState.gridName.

Should be;

 else {
            /* User accepted the changes */
            /* Clear dirty rows */
            _gridNewRows[clientState.gridName] = new Array();
        }

2) When I save the changes that I save don't seem to make it to the server because if I go next then back again my new lines are no-where to be found...

Turns out this isn't a bug in the code but a limitation of the demo, it was trivial to fix so that the repository is persistent and stores the data that's added. Would improve the perception of the demo.

3). I'd like to see buttons for deleting items in the list and buttons for editing existing rows. That would be great.

/* Internal wrapper for the post callback */
function _onAfterGridSave(data) {
    var clientState = _currentInsertState;
    _currentInsertState = null;

    /* If client has specified a callback method, run it and check for cancellation */
    if (clientState.callback != null && clientState.callback != undefined) {
        if (!clientState.callback(data)) {
            /* User has cancelled the operation - make rows editable */
            var currGridRows = _gridNewRows[clientState.gridName];
            var currGrid = $("#" + clientState.gridName);

            var i = 0;
            for (i = 0; i < currGridRows.length; i++)
                currGrid.editRow(currGridRows[i]);

            return;
        }
        else {
            /* User accepted the changes */
            /* Clear dirty rows */
            _gridNewRows[clientState.gridName] = new Array();
        }
    }
}
/* Internal wrapper for the post callback */
function _onAfterGridSave(data) {
    var clientState = _currentInsertState;
    _currentInsertState = null;

    /* If client has specified a callback method, run it and check for cancellation */
    if (clientState.callback != null && clientState.callback != undefined) {
        if (!clientState.callback(data)) {
            /* User has cancelled the operation - make rows editable */
            var currGridRows = _gridNewRows[clientState.gridName];
            var currGrid = $("#" + clientState.gridName);

            var i = 0;
            for (i = 0; i < currGridRows.length; i++)
                currGrid.editRow(currGridRows[i]);

            return;
        }
        else {
            /* User accepted the changes */
            /* Clear dirty rows */
            _gridNewRows[gridName] = new Array();
        }
    }
}
Coordinator
Apr 28, 2011 at 7:39 AM
Edited Apr 28, 2011 at 7:41 AM

Hi,

1. Thanks for the heads up! the fix has been comitted.

2. I tried to make the demo project as simple, keeping the focus on the grid and less on the project as a hole, but I accept the fact that making it a bit more realistic might have made it more understandable.

I'll try and make the demo project a bit more rich and complete for the next release.

3. Basically when adding an import to MVC.Controls.Grid to the view's, you get the following extension helper methods:

Html.GridSaveButton, Html.GridUpdateButton, Html.GridDeleteButton, Html.GridCancelButton, Html.GridSelectButton

This methods were not tested properly and are not bes designed (understatement), but might be just what you need.

I'll update this method to a more comprehensive alternative in the next release, but it might take an additional couple of weeks so I wouldnt wait for them...