将变量转移到另一个视图

我在我的config.js文件中声明了一个全局变量:

var  _StockClass = 0;

然后我从这样的视图中设置它的价值:

function GetListItem(e) {
    // alert('Click for Id=' + itemData.Id.toString() + ', Name=' + itemData.Name);
    _StockClass = e.StockClassID.toString();

}

和查看代码:

<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>

现在,在我想用它的观点上,我说:

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
});

我调试过,它一直saying _StockClass0

如何在视图中设置其值,并将其转移到另一个视图?


将数据源代码保存在onDeviceReady事件中,该事件将等待您的视图加载。 并将该变量传递给另一个视图...在app.config.js中声明变量为全局变量。

链接地址: http://www.djcxy.com/p/31103.html

上一篇: Transfer variable to another view

下一篇: Angular : DevExtreme DataGrid State Storing