Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejavascript
titleui.js
isc.ListGrid.create({
    "ID": "supplyItem",
    "width": 700, "height": 224, "alternateRecordStyles": true,
    "dataSource": supplyItem,
    "showFilterEditor": true,
    "autoFetchData":true,
    "dataPageSize":20,
    "canEdit":true,
    "canRemoveRecords":true,
    "autoSaveEdits": false
});

Additionally,add a button which will perform the save request:

Code Block
languagejavascript
titleui.js
isc.IButton.create({
    "top": 250,
    "left": 100,
    "title": "Save all",
    "click": "supplyItem.saveAllEdits()"
});

...

Code Block
themeEclipse
languagejavascript
titlesupplyItem.js
isc.RestDataSource.create({
    "ID": "supplyItemsuppyItem",
    "fields": [
		{ name: [
        {"name":"itemID", "type": "sequence", "hidden": "true", "primaryKey": "true" },
        { "name": "itemName", "type": "text", "title": "Item", "length": "128", "required": "true" },
        { "name": "SKU", "type": "text", "title": "SKU", "length": "10", "required": "true" },
        { "name": "description", "type": "text", "title": "Description", "length": "2000" },
        { "name": "category", "type": "text", "title": "Category", "length": "128", "required": "true" },
        { "name": "units", "type": "enum", "title": "Units", "length": "5",
            "valueMap": ["Roll", "Ea", "Pkt", "Set", "Tube", "Pad", "Ream", "Tin", "Bag", "Ctn", "Box"]
        },
        { "name": "unitCost", "type": "float", "title": "Unit Cost", "required": "true",
            "validators": [
                { "type": "floatRange", "min": "0", "errorMessage": "Please enter a valid (positive) cost" },
                { "type": "floatPrecision", "precision": "2", "errorMessage": "The maximum allowed precision is 2" }
            ]
        },
  
        { "name": "inStock", "type": "boolean", "title": "In Stock" },
        { "name": "nextShipment", "type": "date", "title": "Next Shipment"}
   } 	],  
    "dataFormat": "json",
    "operationBindings": [
                { "operationType": "fetch", "dataProtocol": "postMessage", "dataURL": "process.php" },
            				{ "operationType": "add", "dataProtocol": "postMessage", "dataURL": "process.php" },
            				{ "operationType": "update", "dataProtocol": "postMessage", "dataURL": "process.php" },
            				{ "operationType": "remove", "dataProtocol": "postMessage", "dataURL": "process.php" }
            ] 
});
 

Process handler 

Code Block
themeEclipse
languagephp
titleprocess.php
<?php                           
    require_once 'RPCManager.php';
    require_once 'rb.php';
    
    R::setup('mysql:host=localhost;dbname=smartclient','root','apmsetup');      
    $rpc_manager = new RPCManager($HTTP_RAW_POST_DATA);
    R::close();
    return $rpc_manager->processRequest();                  
?>

...