用骨干更新jqgrid中的单元格

时间:2014-04-11 10:08:13

标签: jquery backbone.js jqgrid

是否可以为td元素赋值和id并通过此id访问此元素并更改值?

可以制动所有jqgrid对象吗?

我有骨干模型,名为sensorModel,和sensorCollection,并且值:更改后我在tableView中调用了回调函数:

 changeGridValue: function(model) {
        var id = model.get('id');
        console.log(model.get('value'));
        console.log(model);
        this.container.find('table').jqGrid('setCell', 1, id, model.get('value') + " " + model.get('unit'));

        this.reloadView();
        //this.jqgridElem.setCell();

},

但问题是,如果我想在单元格中放置值,我必须知道行的索引,但是这个索引存储在我的集合中。

那么可以使用更改后的值传递参数集合和模型吗?

1 个答案:

答案 0 :(得分:0)

我不确定你想做什么,但看起来你想要"提交"您使用viewA或viewB在signInView中的表单(例如,loginPage和loginDropDown)。我是对的吗?

define(["jquery" ,
    "underscore" ,
    "backbone" ,
    "viewA",
    "viewB",
    //the others file
    ],function($ , _ , Backbone, viewA, viewB){

    var signInView = Backbone.View.extend({
      initialize: function() {
        // listen to viewA and viewB and fire signIn action in this view
        this.listenTo(this.viewA, "signIn", this.signIn);
        this.listenTo(this.viewB, "signIn", this.signIn);
      },
      events : {
        'click #signInBtn' : 'signIn'
      },
      signIn : function(youCanPassYourFormModelHere){
        this.trigger("signIn");
      }
    });
    return viewB;
});

您修改的代码(添加的触发器):

define(["jquery" ,
    "underscore" ,
    "backbone" ,
    "text!templates/Layout/signIn.html"
    //the others file
    ],function($ , _ , Backbone, SignIn){

    var viewA = Backbone.View.extend({
      initialize: function() {

      },
      events : {
       'click #signInBtn' : 'signIn'
      },
      signIn : function(){
       this.trigger("signIn", formModel);
      }
    });
    return viewA;
});


define(["jquery" ,
    "underscore" ,
    "backbone" ,
    "text!templates/Layout/signIn.html"
    //the others file
    ],function($ , _ , Backbone, SignIn){

    var viewB = Backbone.View.extend({
      initialize: function() {

      },
      events : {
       'click #signInBtn' : 'signIn'
      },
      signIn : function(){
       this.trigger("signIn", formModel);
      }
    });
    return viewB;
});