bbGrid icon indicating copy to clipboard operation
bbGrid copied to clipboard

Undefined selected model

Open ramiromd opened this issue 11 years ago • 5 comments

Hi all, im try to get the selected model via onClick button event. I have the multiselect option set as true, and when select an item an click the button, the selected model is undefined.

// psuedo var this is the view, not works with this.view (as the doc says). var models = this.getSelectedModels(); console.log(models);

My model and collection are defined as follows:

var Model = Backbone.Model.extend();

var ModelsCollection = Backbone.Collection.extend({ model: Model, url: Routing.generate('usuarios_retrieve') });

Any ideas ?

ramiromd avatar Jan 28 '14 20:01 ramiromd

Can you write full code for bbGrid.View ?

direct-fuel-injection avatar Jan 29 '14 05:01 direct-fuel-injection

My full code is:

var Model = Backbone.Model.extend();
var ModelsCollection = Backbone.Collection.extend({
     model: Model,
     url: Routing.generate('usuarios_retrieve')
});
var myCollection = new ModelsCollection();

var edit_user = function(){
      var models = this.getSelectedModels();
      console.log(models);
};

var myButtons = [
    {title: '<i class="icon-edit"></i>', onClick: edit_user}
];

var grid = new bbGrid.View({
     container: $("#datagrid"),
     collection: myCollection,
     colModel: [
          {title: 'ID', name: 'iduser'},
          {title: 'Apellido', name: 'apellido', sorttype: 'string', filter: true, filterType: 'input'},
          {title: 'Nombre', name: 'nombre', filter: true, filterType: 'input'},
          {title: 'DNI', name: 'dni'},
          {title: 'Fecha nacimiento', name: 'fecha_de_nacimiento'},
          {title: 'Domicilio', name: 'domicilio'},
          {title: 'Email', name: 'email'}
      ],
      autofetch: true,
      rows: 10,
      rowList: [5, 10, 15, 20, 25],
      buttons: myButtons,
      multiselect: true
});

Note: The grid view is render ok.

ramiromd avatar Jan 29 '14 22:01 ramiromd

It's working. http://jsfiddle.net/P7utr/ your code below. What version of underscore? (try to update to latest).

direct-fuel-injection avatar Jan 30 '14 05:01 direct-fuel-injection

Oh, im using the latest stable (1.5.2).

ramiromd avatar Jan 30 '14 22:01 ramiromd

I am also facing same issue. Any update on this bug?

ravibiz avatar May 06 '17 09:05 ravibiz