[ALOY-639] Support data-binding for other than Backbone collections

GitHub Issuen/a
TypeNew Feature
Affected Version/sn/a
Fix Version/sn/a
ComponentsModels, Runtime
Labelsalloy, data-binding
ReporterFokke Zandbergen
AssigneeFeon Sua Xin Miao


This issue was part of ALOY-504 but now separated. Now we have the dataFunction attribute in place, we can manually trigger updating a data-bound view. This issue takes it a step further and asks for the generated data-function to be able to work with general objects/arrays. index.xml
<TableView dataFunction="fillTable" dataTransform="transformItem" dataFilter="filterData">
  <TableViewRow title="{title}" />
function filterData(data) {
  return _.where(data, { title: 'Two' }); 

function transformItem(item) {
  var transform = _.clone(item);
  transform.title = title + ' ' + _.random(1, 10);
  return transform;

  { title: 'One'   },
  { title: 'Two'   },
  { title: 'Three' }
generated data-funtion
function fillTable(data) {
  // Apply filter on passed data instead of a collection
  var models = dataFilter(data);

  // remove existing stuff like normal

  // Use Underscore's each instead of a for-loop
  _.each(data, function (_alloyId*N*) {
    // Apply transform on item like normal
    _alloyId*N*.__transform = dataTransform(_alloyId*N*);
    // Generate and add views like normal
Some notes: * The dataTransform and dataFilter implementations won't need to be changed since the user is responsible for what happens inside these functions and the input and output when called on regular objects would be exactly the same. * The generated data-function would need to accept an object/array as argument. * The generated data-function would need to use _.each instead of a for-loop, because it needs to support any loop-able data. * In case a dataCollection attribute was specified, the first line in the generated data-funtion could be changed to var models = dataFilter(data || _alloyId*N*); so the data-function would both work on the bound collection as well as manually called with custom data.


  1. Fokke Zandbergen 2014-08-29 Thanks for changing this to high priority... still 'd like this very much ;)
  2. me du 2015-01-17 I also like to have it - see my question: https://developer.appcelerator.com/question/180238/howto-fire-event-to-refresh-view

JSON Source