3.0 beta 2

Sample code to edit grid data and send to sever

Here is a sample code to edit grid data and send data to sever.

<script>
    var editLine=-1;
    var myCells = [
        ["MSFT","Microsoft Corporation", "314,571.156"],
        ["ORCL", "Oracle Corporation", "62,615.266"],
        ["BLAH", "Blah Corporation", "900,688.266"]
    ];

    var myHeaders = ["Ticker", "Company Name", "Market Cap."];

    // create grid object
    var obj = new AW.UI.Grid;

    // assign cells and headers text
    obj.setCellText(myCells);
    obj.setHeaderText(myHeaders);

    // set number of columns/rows
    obj.setColumnCount(myHeaders.length);
    obj.setRowCount(myCells.length);

    obj.onControlClicked = 
    function(){
        editLine = this.getCurrentRow();
        var a = myCells[editLine];
        input0.setControlText(a[0]);
        input1.setControlText(a[1]);
        input2.setControlText(a[2]);
    };



    var label0 = new AW.UI.Label;
    label0.setId("label0");
    label0.setControlText(myHeaders[0]);

    var input0 = new AW.UI.Input;
    input0.setId("input0");
    input0.setControlText("");


    var label1 = new AW.UI.Label;
    label1.setId("label1");
    label1.setControlText(myHeaders[1]);

    var input1 = new AW.UI.Input;
    input1.setId("input1");
    input1.setControlText("");


    var label2 = new AW.UI.Label;
    label2.setId("label2");
    label2.setControlText(myHeaders[2]);

    var input2 = new AW.UI.Input;
    input2.setId("input2");
    input2.setControlText("");



    var button1 = new AW.UI.Button;
    button1.setId("button1");
    button1.setControlText("Update");

    button1.onClick = function(){
           var data;
           data = "oldticker=" + escape(myCells[editLine][0]) 
                + "&newticker=" + escape(input0.getControlText())
                + "&name=" + escape(input1.getControlText())
                + "&cap=" + escape(input2.getControlText());
       sendData(data);
    }



    // write grid to the page
    document.write(obj);
    document.write('<br>');
    // write controls to the page
    document.write(label0+'<br>'+input0+'<br>');
    document.write(label1+'<br>'+input1+'<br>');
    document.write(label2+'<br>'+input2+'<br>');
    document.write(button1);

    function sendData(data){
       //use http request or something to send data to serever
       alert(data)
    }



</script>
Biju
April 30,
Biju
April 30,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.