From 0e4f22717810943066a9919185b508d735f90e5d Mon Sep 17 00:00:00 2001 From: Andrzej Popowski Date: Tue, 26 Jan 2016 09:13:38 +0100 Subject: [PATCH] [Datacontrol] - upgrade of API reference and tutorial Change-Id: Ie8c26a3fcdac0d059ea17593a09b8dc96c64fddb Signed-off-by: Andrzej Popowski --- .../html/web/tizen/application/data_tutorial_w.htm | 5 ++- .../html/device_api/mobile/tizen/datacontrol.html | 45 +++++++++++++++------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/org.tizen.tutorials/html/web/tizen/application/data_tutorial_w.htm b/org.tizen.tutorials/html/web/tizen/application/data_tutorial_w.htm index e0f4b94..fc99617 100644 --- a/org.tizen.tutorials/html/web/tizen/application/data_tutorial_w.htm +++ b/org.tizen.tutorials/html/web/tizen/application/data_tutorial_w.htm @@ -197,8 +197,11 @@ function onSelectSuccess(result, id) try {    var columns = ["WORD", "WORD_DESC" ]; +   var order = "WORD ASC"; +   var page = null; +   var maxNumberPerPage = null;    globalReqId++; -   globalSQLConsumer.select(globalReqId, columns, "WORD='tizen1'", onSelectSuccess, onRequestError); +   globalSQLConsumer.select(globalReqId, columns, "WORD='tizen1'", onSelectSuccess, onRequestError, page, maxNumberPerPage, order); }
  • To update data, use the update() method of the SQLDataControlConsumer interface:

    diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/datacontrol.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/datacontrol.html index 74f6d31..c9af8c8 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/datacontrol.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/datacontrol.html @@ -83,7 +83,7 @@ Please read the insert (unsigned long reqId, RowData insertionData, optional DataControlInsertSuccessCallback? successCallback, optional DataControlErrorCallback? errorCallback)
    void update (unsigned long reqId, RowData updateData, DOMString where, optional DataControlSuccessCallback? successCallback, optional DataControlErrorCallback? errorCallback)
    void remove (unsigned long reqId, DOMString where, optional DataControlSuccessCallback? successCallback, optional DataControlErrorCallback? errorCallback)
    - void select (unsigned long reqId, DOMString[] columns, DOMString where, DataControlSelectSuccessCallback successCallback, optional DataControlErrorCallback? errorCallback, optional unsigned long? page, optional unsigned long? maxNumberPerPage) + void select (unsigned long reqId, DOMString[] columns, DOMString where, DataControlSelectSuccessCallback successCallback, optional DataControlErrorCallback? errorCallback, optional unsigned long? page, optional unsigned long? maxNumberPerPage, optional DOMString? order) MappedDataControlConsumer @@ -323,7 +323,7 @@ The string consists of one or more components, separated by a slash('/'). void select(unsigned long reqId, DOMString[] columns, DOMString where, DataControlSelectSuccessCallback successCallback, optional DataControlErrorCallback? errorCallback, - optional unsigned long? page, optional unsigned long? maxNumberPerPage) raises(WebAPIException); + optional unsigned long? page, optional unsigned long? maxNumberPerPage, optional DOMString? order) raises(WebAPIException); };

    Since: @@ -605,9 +605,9 @@ The string consists of one or more components, separated by a slash('/').

    - Selects the specified columns to be queried. The result set of the specified columns is retrieved from a table owned by an SQL-type data control provider. + Selects the specified columns to be queried. The result set of the specified columns is retrieved from a table owned by an SQL-type data control provider. If page and maxNumberPerPage parameters are not specified and result set contains more than 20 rows, only first 20 rows are included in the result.
    -
    void select(unsigned long reqId, DOMString[] columns, DOMString where, DataControlSelectSuccessCallback successCallback, optional DataControlErrorCallback? errorCallback, optional unsigned long? page, optional unsigned long? maxNumberPerPage);
    +
    void select(unsigned long reqId, DOMString[] columns, DOMString where, DataControlSelectSuccessCallback successCallback, optional DataControlErrorCallback? errorCallback, optional unsigned long? page, optional unsigned long? maxNumberPerPage, optional DOMString? order);
                  

    Since: @@ -620,7 +620,10 @@ The string consists of one or more components, separated by a slash('/').

    Privilege: http://tizen.org/privilege/datacontrol.consumer -

    +

    +

    Remark : + order is supported since Tizen 3.0 +

    Parameters:

      @@ -650,9 +653,13 @@ The string consists of one or more components, separated by a slash('/').
    • maxNumberPerPage [optional] [nullable]: - The maximum number of rows on a page. -
    • -
    + The maximum number of rows on a page. The maximum allowed value is equal to 1024. +
  • +
  • +order [optional] [nullable]: +The sorting order of the selected rows.
    It is an SQL ORDER BY clause excluding the ORDER BY itself such as column1, column2 ASC. If it is set to null, the order in which the rows are returned is undefined. +
  • +

    Exceptions:

    @@ -678,14 +685,17 @@ The string consists of one or more components, separated by a slash('/').

    Code example:

     function getValueSuccessCB(result, id)
      {
    +     console.log("getValueSuccessCB result.length: " + result.length);
          var length = result.length;
          for (var i = 0; i < length; i++)
          {
    +         var rowData = "| ";
              var j = 0;
              for (j = 0; j < result[i].columns.length; j++)
              {
    -             console.log("column: " + result[i].columns[j] + ", value: " + result[i].values[j]);
    +             rowData += "column: " + result[i].columns[j] + ", value: " + result[i].values[j] + " | ";
              }
    +         console.log(rowData);
          }
      }
     
    @@ -695,11 +705,18 @@ The string consists of one or more components, separated by a slash('/').
      }
     
      try {
    -     // Defines globalReqId before
    +     // globalSQLConsumer and globalReqId should be defined before.
          // Increases globalReqId for uniqueness
    -     var array = ["WORD", "WORD_DESC" ];
    -     globalReqId++;
    -     globalSQLConsumer.select(globalReqId, array, "WORD='tizen1'", getValueSuccessCB, errorcb);
    +     var columns = ["WORD", "WORD_DESC" ];
    +     var whereClause = "1";
    +     console.log("----- Calling for ascending order -----");
    +     globalSQLConsumer.select(globalReqId, columns, whereClause, getValueSuccessCB, errorcb,
    +              null, null, "WORD_DESC ASC");
    +     setTimeout( function() {
    +        console.log("----- Calling descending order -----");
    +        globalSQLConsumer.select(globalReqId, columns, whereClause, getValueSuccessCB, errorcb,
    +                  null, null, "WORD_DESC DESC");
    +     }, 1000);
      }
      catch (err) {
          console.log (err.name +": " + err.message);
    @@ -1405,7 +1422,7 @@ The string consists of one or more components, separated by a slash('/').
     
             void select(unsigned long reqId, DOMString[] columns, DOMString where,
                         DataControlSelectSuccessCallback successCallback, optional DataControlErrorCallback? errorCallback,
    -                    optional unsigned long? page, optional unsigned long? maxNumberPerPage) raises(WebAPIException);
    +                    optional unsigned long? page, optional unsigned long? maxNumberPerPage, optional DOMString? order) raises(WebAPIException);
         };
     
         [NoInterfaceObject] interface MappedDataControlConsumer : DataControlConsumerObject {
    -- 
    2.7.4