Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problem with setValue

    Hi,

    Any idea why value assigned using form.setValue doesn't update to grid when edit complete.

    Code:
    var orderData = [
        { No: 1, Item: "10010", Description: "Item 10010", Quantity: 10.0, Uom: "PCS", UnitPrice: 2.0 },    
        { No: 2, Item: "10011", Description: "Item 10011", Quantity: 15.0, Uom: "PCS", UnitPrice: 2.5 },
        { No: 3, Item: "10012", Description: "Item 10012", Quantity: 20.0, Uom: "PCS", UnitPrice: 4.0 },
        { No: 4, Item: "10013", Description: "Item 10013", Quantity: 10.0, Uom: "PCS", UnitPrice: 3.0 },
        { No: 5, Item: "10014", Description: "Item 10014", Quantity: 15.0, Uom: "PCS", UnitPrice: 1.0 },
        { No: 6, Item: "10015", Description: "Item 10015", Quantity: 20.0, Uom: "PCS", UnitPrice: 1.5 }
    ];
    isc.DataSource.create({
        ID: "orderDS",
        fields: [
            { name: "No", title: "No", type: "integer", canEdit: false, primaryKey: true },
            { name: "Item", title: "Item", startRow: true, edititorType: "ComboBoxItem", optionDataSource: "itemDS", pickListWidth: 300, pickListFields: [{ name: "Item" }, { name: "Description" }, { name: "Uom" }, { name: "UnitPrice"}],
                changed: function (form, item, value) {
                    var record = item.getSelectedRecord();
                    if (record) {
                        form.setValue("Description", record.Description); 
                        form.setValue("Uom", record.Uom);
                        form.setValue("UnitPrice", record.UnitPrice);
                    }
                }
            },
            { name: "Description", title: "Description" },
            { name: "Quantity", title: "Quantity", type: "float" },
            { name: "Uom", title: "Uom" },
            { name: "UnitPrice", title: "Unit Price", type: "float" }
        ],
        clientOnly: true,
        testData: orderData
    });
    var itemData = [
        { Item: "10010", Description: "Item 10010", Uom: "PCS", UnitPrice: 2.0 },
        { Item: "10011", Description: "Item 10011", Uom: "PCS", UnitPrice: 2.5 },
        { Item: "10012", Description: "Item 10012", Uom: "PCS", UnitPrice: 4.0 },
        { Item: "10013", Description: "Item 10013", Uom: "PCS", UnitPrice: 3.0 },
        { Item: "10014", Description: "Item 10014", Uom: "PCS", UnitPrice: 1.0 },
        { Item: "10015", Description: "Item 10015", Uom: "PCS", UnitPrice: 1.5 },
        { Item: "10020", Description: "Item 10020", Uom: "PCS", UnitPrice: 2.0 },
        { Item: "10021", Description: "Item 10021", Uom: "PCS", UnitPrice: 2.5 },
        { Item: "10022", Description: "Item 10022", Uom: "PCS", UnitPrice: 4.0 },
        { Item: "10023", Description: "Item 10023", Uom: "PCS", UnitPrice: 3.0 },
        { Item: "10024", Description: "Item 10024", Uom: "PCS", UnitPrice: 1.0 },
        { Item: "10025", Description: "Item 10025", Uom: "PCS", UnitPrice: 1.5 }
    ];
    isc.DataSource.create({
        ID: "itemDS",
        fields: [
            { name: "Item", title: "Item" },
            { name: "Description", title: "Description" },
            { name: "Uom", title: "Uom" },
            { name: "UnitPrice", title: "Unit Price", type: "float" }
        ],
        clientOnly: true,
        testData: itemData
    });
    isc.DynamicForm.create({
        ID: "editOption",
        width: 300, height: 30,
        fields: [
            { name: "option", title: "Edit option", type: "comboBoxItem",
                valueMap: { "Grid": "Grid (inline)", "Form": "Form" },
                defaultValue: "Grid",
                changed: function (form, item, value) {
                    if (value == "Grid") {
                        orderForm.clearValues();
                        orderList.editEvent = "doubleClick";
                        ts.hide();
                        orderForm.hide();
                    }
                    else {
                        orderList.cancelEditing();
                        orderList.editEvent = "none";
                        ts.show();
                        orderForm.show();
                        orderForm.setDisabled(true);
                    }
                }
            },
            { name: "cmdAddNew", title: "Add new", type: "button", width: 100,
                click: function (form, item) {
                    var newRecord = { No: orderList.getTotalRows() + 1, Quantity: 0 };
                    if (form.getValue("option") == "Grid") {
                        orderList.startEditingNew(newRecord);
                    }
                    else {
                        orderForm.editNewRecord(newRecord);
                        orderForm.setDisabled(false);
                    }
                }
            }
        ]
    });
    isc.ListGrid.create({
        ID: "orderList",
        top: 60, width: 500, height: 200, alternateRecordStyles: true,
        dataSource: orderDS,
        autoFetchData: true,
        autoSaveEdits: false, 
        canEdit: true, editEvent: "doubleClick",
        recordDoubleClick: function (viewer, record, recordNum, field, fieldNum, value, rawValue) {
            orderForm.editRecord(orderList.getEditedRecord(recordNum));
            orderForm.setDisabled(false);
        }
    });
    isc.IButton.create({ ID: "cmdOk", title: "Ok", width: 100, click: "if (orderForm.validate()) {orderList.setEditValues(orderForm.getValue('No') - 1, orderForm.getValues()); orderForm.clearValues(); orderForm.setDisabled(true); }" });
    isc.IButton.create({ ID: "cmdCancel", title: "Cancel", width: 100, click: "orderForm.clearValues(); orderForm.setDisabled(true);" });
    isc.ToolStrip.create({ ID: "ts", autoDraw: false, top: 270, width: 200, height: 24, members: [cmdOk, cmdCancel] });
    isc.DynamicForm.create({
        ID: "orderForm",
        dataSource: orderDS,
        autoDraw: false,
        top: 300,
        width: 500,
        numCols: 4, colWidths: [50, 200, 50, 200]
    });

    #2
    Dear experts, am I doing the wrong way or there is a bug. Please advise.

    Comment


      #3
      Not sure what you're asking here. In this test case the "Ok" button takes the values from the form and passes them to the grid as edit values and the grid updates to reflect these. What's not behaving as expected?

      Comment


        #4
        Please try on Grid inline editing, not Form editing.

        Double click on a row, select a different value from Item picklist, notice the Description and UnitPrice changed, when navigate to other row or hit the enter key, the changes not update to grid.

        Comment


          #5
          Originally posted by Isomorphic
          Not sure what you're asking here. In this test case the "Ok" button takes the values from the form and passes them to the grid as edit values and the grid updates to reflect these. What's not behaving as expected?
          Please try on Grid inline editing, not Form editing.

          Double click on a row, select a different value from Item picklist, notice the Description and UnitPrice changed, when navigate to other row or hit the enter key, the changes not update to grid.

          Comment


            #6
            Have you tested based on the above scenario for grid editing.

            Comment

            Working...
            X