Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2697] Setting dataCollection or dataFilter on a Ti.UI.View via <Widget> or <Require> doesn't work

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNeeds more info
Resolution Date2014-06-30T07:30:48.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy
Labelsalloy, arguments
ReporterLee Driscoll
AssigneeMauro Parra-Miranda
Created2013-11-08T11:28:23.000+0000
Updated2016-03-08T07:41:48.000+0000

Description

Hi there, I wish to set-up custom binding logic for a widget using as much standard TiAPI principles as possible. I have the following XML: views/scheduler.xml
<Alloy>
	<Collection src="job" />
	<Window title="Scheduler" navBarHidden="false" layout="vertical">
		<Widget src="uk.co.mycompany.scheduler" dataCollection="job" dataTransform="transformFn" dataFilter="filterFn" startDate="Date.today()" id="schedulerWidget" />
	</Window>
</Alloy>
In my widget's controller I have the following (lazy) tests: widgets/uk.co.mycompany.scheduler/controllers/widget.js
var args = arguments[0] || {};
args['dataCollection'] || Alloy.Globals.Log.error('[FAIL] dataCollection required parameter');
args['dataFilter'] || Alloy.Globals.Log.error('[FAIL] dataFilter required parameter');
args['dataTransform'] || Alloy.Globals.Log.error('[FAIL] dataTransform required parameter');
When I run the code, only dataTransform is present in the arguments object. I have tested in a variety of scenarios, also using the tag. The results were always the same. Lee.

Comments

  1. Mauro Parra-Miranda 2013-11-21

    Hello Lee! Can you please help us with a complete test case? Currently your test case fails because there is no model. Best, Mauro
  2. Lee Driscoll 2013-11-21

    Hi Mauro ! Apologies for that - here's is the model file What else do you need? models/job.js
       var moment = require('alloy/moment');
       
       exports.definition = {
           config : {
               columns : {
                   'jobID' : 'TEXT',
                   'description' : 'TEXT',
                   'location' : 'TEXT',
                   'startTime' : 'TEXT',
                   'endTime' : 'TEXT',
                   'story' : 'BLOB'
               },
               adapter : {
                   idAttribute : 'jobId',
                   type : Ti.Platform.name == 'mobileweb' ? 'localStorage' : 'sql',
                   db_name : 'jobs',
                   collection_name : 'job'
               }
           },
           extendModel : function(Model) {
               if (Model && Model.prototype) {
                   _.extend(Model.prototype, {
                       // extended functions and properties go here
                   });
               }
       
               return Model;
           },
           extendCollection : function(Collection) {
               if (Collection && Collection.prototype) {
                   _.extend(Collection.prototype, {
                       getByWeek : function(weekStart) {
       
                           var weekEnd = moment(weekStart).add('d', 7),
                               sqlQuery,
                               results;
       
                           sqlQuery = ' \
                               SELECT * FROM job \
                               WHERE startTime \
                               BETWEEN ' + weekStart + ' AND ' + weekEnd + '\
                               OR endTime \
                               BETWEEN ' + weekStart + ' AND ' + weekEnd;
       
                           results = this.fetch({
                               query : sqlQuery
                           });
       
                           if (results) {
                               Ti.API.info('Requested jobs found: ' + results);
                           } else {
                               Ti.API.info('No jobs found: ' + results);
                           }
       
                           return results;
                       }
                       // extended functions and properties go here
                   });
               }
       
               return Collection;
           }
       }; 
       
  3. Mauro Parra-Miranda 2013-12-04

    Hello Lee, we will need the widget as well, so we can test exactly the same code than you. Best, Mauro
  4. Mauro Parra-Miranda 2014-06-30

    We didn't get a response from customer.

JSON Source