Collection Contents 上一页 下一页 PDF

UltraLite for M-Business Anywhere User's Guide

Tutorial: A Sample Application for M-Business Anywhere

Lesson 7: Add updates and deletes to your application


This lesson describes code for updating and deleting rows.

Add update and delete functions to your application

  1. Add the Update function to tutorial.js:

    function Update()
    {
      var id;
      try {
        CustomerTable.updateBegin();
    
        id = CustomerTable.schema.getColumnID("fname");
        CustomerTable.setString(id, Cust_FName);
        id = CustomerTable.schema.getColumnID("lname");
        CustomerTable.setString(id, Cust_LName);
        id = CustomerTable.schema.getColumnID("city");
        if( Cust_City.length > 0 ) {
          CustomerTable.setString(id, Cust_City);
        } else {
          CustomerTable.setNull(id);
        }
        id = CustomerTable.schema.getColumnID("phone");
        if( Cust_Phone.length > 0 ) {
          CustomerTable.setString(id, Cust_Phone);
        } else {
          CustomerTable.setNull(id);
        }
        CustomerTable.update();
      } catch( ex ) {
        alert( "Update error: " + ex.getMessage() );
      }
    }
  2. Add the Delete function to tutorial.js:

    function Delete()
    {
      if( CustomerTable.getRowCount() == 0 ) {
        return;
      }
      CustomerTable.deleteRow();
      CustomerTable.moveRelative(0);
    }
  3. Add the following functions to main.html:

    function ClickUpdate()
    {
      FetchForm();
      Update();
      DisplayCurrentRow();
    }
    function ClickDelete()
    {
      Delete();
      DisplayCurrentRow();
    }
  4. Synchronize your M-Business Client and run the application.


Collection Contents 上一页 下一页 PDF