[AC-2697] Setting dataCollection or dataFilter on a Ti.UI.View via <Widget> or <Require> doesn't work
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | n/a |
| Status | Closed |
| Resolution | Needs more info |
| Resolution Date | 2014-06-30T07:30:48.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Alloy |
| Labels | alloy, arguments |
| Reporter | Lee Driscoll |
| Assignee | Mauro Parra-Miranda |
| Created | 2013-11-08T11:28:23.000+0000 |
| Updated | 2016-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
tag. The results were always the same.
Lee.
<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
Hello Lee! Can you please help us with a complete test case? Currently your test case fails because there is no model. Best, Mauro
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; } };Hello Lee, we will need the widget as well, so we can test exactly the same code than you. Best, Mauro
We didn't get a response from customer.