I declare a global variable in my config.js
file :
var _StockClass = 0;
Then I set its value from a view like this :
function GetListItem(e) {
// alert('Click for Id=' + itemData.Id.toString() + ', Name=' + itemData.Name);
_StockClass = e.StockClassID.toString();
}
And the View code :
<div data-options="dxView : { name: 'ProductClass', title: 'Products', pane: 'master' } " >
<div data-options="dxContent : { targetPlaceholder: 'content' } " >
<div data-bind="dxTextBox: { onValueChanged: onSearchTextChanged, mode: 'search' }"></div>
<div data-bind="dxList: { dataSource: dataSource, pullRefreshEnabled: true, itemClickAction: GetListItem }">
<div data-bind="dxAction: '#StockTypeViews/{StockClassID}'" data-options="dxTemplate : { name: 'item' } " >
<!--
<img height="55" style="padding: 10px; float:left;" data-bind="attr: { src: imageUrlPropertyName }" />
-->
<div class="list-item" data-bind="text: 'Code:' + ' ' + Code()"></div>
<div class="list-item" data-bind="text: 'Description:' + ' ' + Description()"></div>
<div class="list-item" data-bind="text: 'StockClassID:' + ' ' + StockClassID()" style="visibility:hidden"></div>
</div>
</div>
</div>
</div>
Now, on the view I want to use it on I say :
dataSource = new DevExpress.data.DataSource({
store: Prosound.db.StockTypeViews,
map: function(item) {
return new Prosound.StockTypeViewViewModel(item);
},
filter: [['StockClassID', '=', _StockClass], 'and', ['Active', '=', true]]
// searchExpr: 'StockID' //change field here for search
});
I have debugged and it keeps saying _StockClass
is 0
.
How do I set its value in a view, and transfer it to another view?