Offline Data Example 1

Let us consider an example where the details of two Fixed Deposit accounts need to be displayed in the Account Summary widget with offline data on the mobile app. The details of the accounts such as, account number, account name, account type, account status, available balance, etc. along with the Widget ID needs to be in CWEC.BEFORE_DATA_LOAD.

For this example, the CWEC.BEFORE_DATA_LOAD structure would be as follows:

CWEH.registerHandler('CT_ACC_SUMMARY_WGT1',CWEC.BEFORE_DATA_LOAD, 
function (widgetId,paramss,netState,callback)
{
   var params=
   {
      "response":
      {
         "data":
         {
            "ALL_RECORDS":
            [{
                "UNCLEARED_FUND": "10.0",
                "ACCOUNT_NO": "1105926174623",
                "CURRENCY": "USD",
                "TOTAL_COUNT": "5",
                "ACCOUNT_NAME": "TWO",
                "OVER_DRAFT_LMT": "0.0",
                "AVAI_BALANCE": "571140.12",
                "STATUS": "ACTIVE",
                "ACCOUNT_TYPE": "FIXED DEPOSIT ACCOUNT"
             },

             {
                "UNCLEARED_FUND": "10.0",
                "ACCOUNT_NO": "1105926174662",
                "CURRENCY": "USD",
                "TOTAL_COUNT": "5",
                "ACCOUNT_NAME": "ONE",
                "OVER_DRAFT_LMT": "0.0",
                "AVAI_BALANCE": "571140.12",
                "STATUS": "ACTIVE",
                "ACCOUNT_TYPE": "FIXED DEPOSIT ACCOUNT"
             }],

            'ADDITIONAL_DATA':
            {
               'MODIFIED_COLUMN_NAMES':
               {
                  CURRENCY: "Currency"
               }
            }
         },

         syncMode:true,
         cancelLoad:false,
         dataMerge:true,
         uniqueColumn: "ACCOUNT_NO"
      }
   };
   callback.apply(this,[params]);
}); 

CWEH.registerHandler('<WIDGET_ID>',CWEC.AFTER_DATA_LOAD, 
function (widgetId,paramss,netState,callback) 
{
   LOGGER.info('response', response)
}); 

The following screen shot displays the Account Summary widget with and without internet connectivity. The screen shot on the left-hand side shows the Account Summary Widget with remote data (with Internet) and the right-hand side shows the Account Summary widget with local data (without Internet).