View Lists

Abstract

In this tutorial we'll learn to work with lists using various methods that are usually required during developing complex forms and web pages.

Keywords: WindnTrees,CRUD,CRUDS,CRUD2CRUD,View Lists
  • Same View Listing

    Same view (ObjectView,SearchView etc) can be used to load lists other than its original request data as mentioned below:

    //'key' is used to load reference list of records. 'resultfield' represents where records are to be stored.
    view.loadListResult({ uri: '/category', key: null, target: 'List', resultfield: 'CategoriesList', keyfield: 'Title', valuefield: 'Uid' });
    
  • New View Listing

    You may also load required lists by instantiating new view instance.

    //new views (ObjectView, NewView, EditView, SearchView, CRUDView) can be used to load generalized lists
    new ObjectView({
     'uri': '/skilllevel'
    }).loadListResult({ key: null, target: 'List', resultfield: 'SkillLevelsList', keyfield: 'Title', valuefield: 'Uid' });
    
  • SearchView and List Request

    SearchView and CRUDview can be used to load list requests.

    //SearchView (and CRUDView) can be used to load request data in typed manner as below:
    new SearchView({
        'uri': '/skilllevel'
    }).list({
        'target': 'list', //replace with your required server side function
        'contentType': new SkillLevel({}), //replace with 'type' that you want to bind your result with
        'query': { "key": null, "keyword": null }, //enter key, keys, keyword, options related input data here
        'callback': function (data) {
         //process recieved request data
         if (Array.isArray(data)) {
         }
      }
    });
    
  • Lists Synchronization

    View's loadListResult can be used to synchronize load results in a resultant method that is called when all lists have been loaded.

    //loadListResult can be used to synchronize load results in a resultant method like 'OnAllListUpdates' that 
    is called when all lists have been loaded
    
    //define list synchronization method
    view.OnAllListUpdates = function (counter) {
    //if counter value is 0 then all lists have been loaded
    //load form
    if (counter === 0) {
        //perform synchronized action here.
    
      }
    };
    
    //load list results
    view.loadListResult({ uri: '/category', target: 'List', resultfield: 'CategoriesList', keyfield: 'Title', valuefield: 'Uid', 
    counterUpdate: view.OnAllListUpdates }); 
    view.loadListResult({ uri: '/skilllevel', target: 'List', resultfield: 'SkillLevelsList', keyfield: 'Title', valuefield: 'Uid', 
    counterUpdate: view.OnAllListUpdates });
    
  • Summary

    WindnTrees CRUDS provides various means of loading, processing and displaying lists.