.getDataSet()

Previous Next

Fetches records of a data source. These records can then be set in a data set of this data source, or used independently, for example as a list of possible values in an autocompletion input box.

Returns a Promise object.

Syntax

.getDataSet( options )

 

options  ::=  {

      colRef:  column

,     doCount: do-count

,     beginRec: begin-record-index

,     count: count

,     withQueryCondition: with-query-condition

,     condition: condition-object

,     getRows: get-rows

,     replace: replace

,     process: process-function

,     success: success-function

,     error: error-function

}

 

do-count               ::= { true | false }

with-query-condition   ::= { true | false }

get-rows               ::= { true | false }

replace                ::= { true | false }

Options is a struct that can have the following items, all of which are optional.

Do-count is a condition that determines whether a count query must be performed in addition to the query action.

Begin-record-index is the record index nmber of the first record to be fetched. Its default is 1, which identifies the first record.

Count is the maximum amount of records to be queried. Normally, this is limited by the ‘Maximum Number of Records’ property of the data source, but this property allows to override. Specifying the ‘0’ value will fetch all matching records.

With-query-condition is a condition that determines whether the current search values must be included in the query action. The default is ‘true’, but if a query is performed for an autocompletion field for a search condition, this should be set to ‘false’.

Condition-object is a search condition object that identifies the subset of rows that you want to be fetched.

If get-rows is set to 'true', the rows are delivered directly. If get-rows is set to 'false' (the default), the rows are placed in the data source’s row set instead.

If replace is set to 'true' (the default), the rows in the existing row set are completely replaced by the new row set. This setting is superseded by get-rows.

Process-function is a function used to transform the records returned by the server. If specified, its results are passed as a return value.

Success-function is a function called after the data was processed on the client.

Error-function is a function called if an error occurs.

 

Example 1

var cond = {};

cond[col.alias()] = ""; //all values of the column

dsc.getDataSet({

   colRef: col.alias(),

   getRows: true,

   condition: cond,

   replace: false

}).then(function(result) {

   ...

});

 

Example 2

var condition = {};

condition[col] = v + "%";

 

$.udb(d).getDataSet({

   count: $.udb(d).dataSetSize(),

   getRows: true,

   replace: false,

   condition: condition,

   process: function(rows) {

       var values = [];

       for (var i = 0; i < rows.length; i++) {

           if (rows[i] && !check[rows[i][pkName]]) {

               if (!max || values.length < max)

                   values.push({

                       text: rows[i][colName],

                       value: rows[i][pkName],

                       rowData: rows[i],

                       dsId: d,

                       colName: colName,

                       pkName: pkName});

               check[rows[i][pkName]] = true;

           }

       }

       

       return values;

   }

}).then(function(result) {

   //publish result

   ...

});