Manually Added Tree Records Not Saving

I have a TreeGrid based on a client only datasource (code below). The user can edit the records. When the user has completed the edits, they submit multiple lists in a batch (The update on the server updates the intersections of the multiple lists).

When the user clicks the submit button, I manually retrieve the Tree Nodes and post them to the server. At this point, all edits made against the TreeGrid are gone. For instance, there’s a bool field called ViewPermission. In the tree, was initialized as false, edited to be true. When I iterate the TreeNodes, it’s false. Is there a way to retrieve the the same information that’s being displayed in the TreeGrid? (I use the same technique on ListGrid’s without this issue).

Thanks in advance,

Paul

isc.DataSource.create({ 
        ID: "ShowToUGDefaultPermissionsSTUB",
         fields: [
        { name: "ObjectName", title: "Show/Folder", type: "string", canEdit: false,
            getFieldValue: function(record, value, field, fieldName) {
                var orStr = (XMLTools.selectString(record, ".//Overrides") == true) ? " <b>OR</b>" : "";

                return XMLTools.selectString(record, ".//ObjectName") + orStr;
            } 
        },
        { name: "DivID", title: "DivID", type: "integer", canEdit: false },
        { name: "ShowCategoryID", title: "ShowCategoryID", type: "integer", canEdit: false },
        { name: "ShowCategoryTitle", title: "ShowCategoryTitle", type: "string", canEdit: false },
        { name: "ShowID", title: "ShowID", type: "integer", canEdit: false },
        { name: "ParentID", title: "ParentID", type: "integer", foreignKey: "ShowID", rootValue: "0" },
        { name: "ShowName", title: "ShowName", type: "string", canEdit: false },
        { name: "ShowFolderID", title: "ShowFolderID", type: "integer", canEdit: false },
        { name: "ShowFolderName", title: "ShowFolderName", type: "string", canEdit: false },
        { name: "Sort", title: "Sort", type: "integer", canEdit: false },
        { name: "StartDate", title: "StartDate", type: "date",
            getFieldValue: function(record, value) {
                return getDateValue("min", value);
            }
        },
        { name: "EndDate", title: "EndDate", type: "date",
            getFieldValue: function(record, value) {
                return getDateValue("max", value);
            }
        },
        { name: "ViewPermission", title: "ViewPermission", type: "boolean", width: 60},
        { name: "DownloadPermission", title: "DownloadPermission", type: "boolean", width: 65},
        { name: "EditPermission", title: "EditPermission", type: "boolean", width: 60},
        { name: "UploadPermission", title: "UploadPermission", type: "boolean", width: 60},
        { name: "DeletePermission", title: "DeletePermission", type: "boolean", width: 60},
        { name: "ShowManagerPermission", title: "ShowManagerPermission", type: "boolean", width: 85}
    ],
        testData: [],
        clientOnly: true
});



isc.TreeGrid.create({
    ID: "ShowsToUGsAddShowsList",
    width: "100%",
    showOpenIcons: false,
    showDropIcons: true,
    closedIconSuffix: "",
    canAcceptDroppedRecords: true,
    canDragRecordsOut: false,
    dataSource: "ShowToUGDefaultPermissionsSTUB",
    autoFetchData: false,
    showFilterEditor: false,
    canEdit: true,
    autoSaveEdits: true,
    showAllRecords: false,
    showEmptyMessage: true,
    alternateRecordStyles: true,
    animateFolders: false,
    selectionType: "multiple",
    cellContextClick: "return ShowsToUGsAddShowsListMenu.showContextMenu()",
    
    getIcon: function(node) {
        return null;
    },
    data: isc.Tree.create({
        modelType: "parent",
        rootValue: "0",
        nameProperty: "ObjectName",
        idField: "ShowID",
        parentIdField: "ParentID",
        data: []
    }),
    cellClick: function(record, rowNum, colNum) {
        if (colNum > 0) {
            ShowsToUGsAddShowsList.startEditing(rowNum);
        }
    },
    canEditCell: function(rowNum, colNum) {
        var record = this.getRecord(rowNum),
               fieldName = this.getFieldName(colNum);
        if ((fieldName == "StartDate" || fieldName == "EndDate" || fieldName == "ShowManagerPermission")
                    && record.ShowID == (-1)) {
            return false;
        }
        return this.Super("canEditCell", arguments);
    },
    fields: [
        { name: "ObjectName", title: "Show/Folder", type: "string", canEdit: false, width: 125 },
        { name: "ViewPermission", title: "View", type: "boolean", width: 50 },
        { name: "DownloadPermission", title: "Download", type: "boolean", width: 50 },
        { name: "EditPermission", title: "Edit", type: "boolean", width: 50 },
        { name: "UploadPermission", title: "Upload", type: "boolean", width: 50 },
        { name: "DeletePermission", title: "Delete", type: "boolean", width: 50 },
        { name: "ShowManagerPermission", title: "ShowManager", type: "boolean", width: 75 },
        { name: "StartDate", title: "StartDate", type: "date" },
        { name: "EndDate", title: "EndDate", type: "date" }
    ]
});




function SaveAssignedShowsToUsergroups() {
    var ugs = "";
    var frst = true;
    var shs = [];
    
    if (ShowsToUGsAddShowsList.data.length == 0) {
        alert('There are no Shows to assign to Usergroups.');
        return false;
    }

    frst = true;
    for (y = 0; y < ShowsToUGsUGListTO.data.length; y++) {
        var ug = ShowsToUGsUGListTO.data[y].UserGroupId;
        if (frst == true) { frst = false; } else { ugs += "~"; }
        ugs += ug;
    }


    var folds = ShowsToUGsAddShowsList.data.getChildren(ShowsToUGsAddShowsList.data.getRoot());
    for (f = 0; f < folds.length; f++) {
        shs.push(folds[f]);
//        alert(folds[f].ObjectName + '\n' + folds[f].EditPermission);
    }


    var req = { actionURL: "/admin/service/PermissionPost.ashx",
        httpMethod: 'POST',
        params: {
            method: "update_ShowsToUsergroups",
            shows: shs,
            usergroups: ugs
        },
        callback: 'SaveAssignedUsersToUsergroupsComplete()'
    }

    isc.RPCManager.sendRequest(req);

}

If there are changes that the user made via inline editing and they haven’t been saved, they are accessible via getEditValues() and related APIs. Both the ListGrid and TreeGrid work with editValues in the same way.

This is all assuming that the in-line edit is complete and no longer in edit mode:

I have several ListGrids that I am using for this method.

Every time I iterate over ListGrid.Data all of the users updates are there.

But in the TreeGrid if I do the same thing (the edit is complete and not in edit mode):

var folds = TreeGrid .data.getChildren(TreeGrid .data.getRoot());

This Tree I get back has none of the updates in it. Should I still use getEditValues()?

Paul

If you’re seeing the data on the screen, it’s either in the Tree or in the unsaved editValues - there’s nowhere else to hide it!

To get a list of all of the rows for which there are unsaved edit values, call getAllEditRows() on the treeGrid.

If you're seeing the data on the screen, it's either in the Tree or in the unsaved editValues - there's nowhere else to hide it!

I am sorry. I thought there may be an issue with the library if I was getting different behavior between the ListGrid and the TreeGrid. I was not attempting to suggest that any data was being concealed in some way.

I also wanted to clarify, since it appeared as though you thought the Line was still in edit mode.

That was an attempt at humor on our part :slight_smile: Should have added the obligatory smiley :slight_smile:

np.

I also just discovered that this is causing another issue.

In a TreeGrid bound to a local datasource if you make an edit on a node and then collapse or expand the node or its parent, the edits disappear.

Be sure you have a primary key declared in the DataSource. It’s not valid to edit without one.

I’ve been a developer for 25 years. I’ve written systems based on complex computational algorithms, managed groups of several hundred developers to achieve on-time milestones under the most demanding schedules.

It’s times like this that I feel humbled. Moronic even.

I am reminded of the immortal words of Socrates who said “True knowledge exists in knowing that you know nothing.”

Thank you for pointing out the obvious fact that a datasource needs primary keys in order to save records properly.

hmph!

I marked the fields as primary keys, still no effect.

I think there’s an issue with the TreeGrid object.

Also, I figured maybe the way to go was to create a transaction table on the server to hold the information. I created a TreeGrid which points to it.

If I open a folder node. Make changes to the leaf or parent and then collapse or expand the parent, all changed disappear in the node and its children.

I’m going to open a new thread for the saving of the nodes against a real table.

As with the other thread you started, multiple primary key fields might be the issue here?