We have one grid panel within Ext.Window. The scroll bar of gridpanel is automatically moving up while scrolling it isn't working properly and when Ext.Window is expanded the grid panel is not expanding. I guess some property has to be set?. Will using autoExpandColumn in gridpanel solve the problem?
extWin=new Ext.Window({
title:"Locate Managed Object",items:[new Ext.grid.GridPanel({
title: "Managed Elements",
region: "center",
height:250,
width:500, renderTo:"tree-id",
viewConfig: {forceFit: true},
store: store,
sm: new GeoExt.grid.FeatureSelectionModel({selectControlelect}),
cm: new Ext.grid.ColumnModel({
defaults: {
sortable: true
},
columns: [
{header:"Managed Elements",dataIndex:"fid"}
]
})
})]
});
extWin.show();
I have added layout:'fit' to this and expanded is working fine but scroll isn't working. Please correct if I'm wrong at any point.
Here is the working example. If you encounter any problem, let me know.
The trick is, layout property. Just set container's layout property fit ( in this case container is window ) and don't give any size property for grid, like width, height.
Sencha Fiddle - GridPanel in Window
Ext.onReady(function(){
function createFakeData(count) {
var firstNames = ['Ed', 'Tommy', 'Aaron', 'Abe', 'Jamie', 'Adam', 'Dave', 'David', 'Jay', 'Nicolas', 'Nige'],
lastNames = ['Spencer', 'Maintz', 'Conran', 'Elias', 'Avins', 'Mishcon', 'Kaneda', 'Davis', 'Robinson', 'Ferrero', 'White'],
ratings = [1, 2, 3, 4, 5],
salaries = [100, 400, 900, 1500, 1000000];
var data = [];
for (var i = 0; i < (count || 25); i++) {
var ratingId = Math.floor(Math.random() * ratings.length),
salaryId = Math.floor(Math.random() * salaries.length),
firstNameId = Math.floor(Math.random() * firstNames.length),
lastNameId = Math.floor(Math.random() * lastNames.length),
rating = ratings[ratingId],
salary = salaries[salaryId],
name = Ext.String.format("{0} {1}", firstNames[firstNameId], lastNames[lastNameId]);
data.push({
rating: rating,
salary: salary,
name: name
});
}
return data;
}
Ext.define('Employee', {
extend: 'Ext.data.Model',
fields: [
{name: 'rating', type: 'int'},
{name: 'salary', type: 'float'},
{name: 'name'}
]
});
// create the Data Store
var store = Ext.create('Ext.data.Store', {
id: 'store',
pageSize: 50,
buffered: true,
purgePageCount: 0,
model: 'Employee',
proxy: {
type: 'memory'
}
});
Ext.create('Ext.window.Window', {
title: 'Hello',
height: 500,
width: 400,
closable: false,
collapsible: true,
layout: {
type: 'fit'
},
items: {
xtype: 'grid',
border: false,
store: store,
loadMask: true,
disableSelection: true,
invalidateScrollerOnRefresh: false,
viewConfig: {
trackOver: false
},
columns: [
{xtype:'rownumberer',width:40,sortable:false},
{text: 'Name',flex:1,sortable:true,dataIndex:'name'},
{text: 'Rating',width:125,sortable:true,dataIndex:'rating'},
{text: 'Salary',width:125,sortable:true,dataIndex:'salary',align:'right',renderer:Ext.util.Format.usMoney}
]}
}).show();
var data = createFakeData(500),
ln = data.length,
records = [],
i = 0;
for (; i < ln; i++) {
records.push(Ext.ModelManager.create(data[i], 'Employee'));
}
store.loadData(records);
});
Related
I have a extjs grid with local paging.
In order to achieve local paging, I have provided memory proxy in store.
My grid also contains checkboxmodel.
But my problem is that when I click on selectAll button, only current page's data is selected.
Is there any way that when I click on selectAll button, the data from my proxy store should be selected which has the entire data of all pages.
Please find my grid below.
Thanks in advance.
Ext.create('Ext.data.Store', {
id: 'simpsonsStore',
fields: ['dummyOne', 'dummyTwo'],
pageSize: 50,
proxy: {
type: 'memory',
enablePaging: true
},
data: (function () {
var i,
data = [];
for (i = 0; i < 200; i++) {
var obj = {};
obj.dummyOne = Math.random() * 1000;
obj.dummyTwo = Math.random() * 1000;
data.push(obj);
}
return data;
})()
});
var grid = {
xtype: 'grid',
height: '100%',
title: "Grid Panel",
selModel: {
type: 'checkboxmodel',
},
store: 'simpsonsStore',
columns: [{
"xtype": "numbercolumn",
"dataIndex": "dummyOne",
"text": " dummyOne"
}, {
"xtype": "numbercolumn",
"dataIndex": "dummyTwo",
"text": "dummyTwo"
}],
bbar: {
xtype: 'pagingtoolbar',
displayInfo: true
}
};
Ext.create({
xtype: 'window',
items: [grid],
width: 500,
layout: 'card',
height: 500,
autoShow: true
});
This is intended behaviour. Imagine you have a paged store with 10.000 rows total, showing 10 rows per page. When your users selects all, it is very unlikely that she or he wants to really select 10.000 rows, seeing only 10 rows, 1 of 1000 pages.
If you really want to do something with your entire store, checkbox selection model won't help you. You need to create a copy of your store without pageSize, and loop through it like:
store.each(function (model) {
// do something with model, which is practically a row in the store
});
Here store has to be a store similar to simpsonsStore, but with pageSize: undefined, so that it will contain all records. But you have to think about store size in a real word application, if it is too large, it might lead to performance problems.
You can use the following dirty solution:
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create('Ext.data.Store', {
id: 'simpsonsStore',
fields: ['dummyOne', 'dummyTwo'],
pageSize: 50,
proxy: {
type: 'memory',
enablePaging: true
},
data: (function () {
var i,
data = [];
for (i = 0; i < 200; i++) {
var obj = {};
obj.dummyOne = Math.random() * 1000;
obj.dummyTwo = Math.random() * 1000;
data.push(obj);
}
return data;
})()
});
var grid = {
xtype: 'grid',
height: '100%',
title: "Grid Panel",
selModel: {
type: 'checkboxmodel',
},
store: 'simpsonsStore',
dockedItems: [{
xtype: 'toolbar',
items: [{
xtype: 'button',
text: "Select All",
handler: function () {
var grid = this.up('grid'),
store = grid.getStore();
var allRecords = store.getProxy().getReader().rawData.reduce((akku, modelData) => {
var pageRecord = store.getById(modelData.id);
if (pageRecord) {
akku.push(pageRecord);
} else {
akku.push(store.createModel(modelData));
}
return akku;
}, []);
grid.getSelectionModel().select(allRecords);
console.log(grid.getSelection());
}
}, {
xtype: 'button',
text: "Console Log Selection",
handler: function () {
console.log(this.up('grid').getSelection());
}
}]
}],
columns: [{
"xtype": "numbercolumn",
"dataIndex": "dummyOne",
"text": " dummyOne"
}, {
"xtype": "numbercolumn",
"dataIndex": "dummyTwo",
"text": "dummyTwo"
}],
bbar: {
xtype: 'pagingtoolbar',
displayInfo: true
}
};
Ext.create({
xtype: 'window',
items: [grid],
width: 500,
layout: 'card',
height: 500,
autoShow: true
});
}
});
I am displaying checkboxgroup on a window with other fields too.
But the second time I call the function to display this window with the checkboxgroup the checkboxgroup gets duplicated.
i.e It only displays two times and not multiple times.
Eg : If actual checkbox values are "red" , "green" then the result on second ,third call will be "red" , "red" , "green" , "green".
Even the +Checklist button displays twice on second or more calls.
It displays proper values on first call though.
below is the code I am working on.
var checkboxconfigs = [];
function showassetForm(record,statusname,emptyval)
{
var arrSubTicket = getSubTickets(record.data.Id);
for(z=0;z<arrSubTicket.length;z++)
{
checkboxconfigs.push({ //pushing into array
id:arrSubTicket[z].Id,
boxLabel:arrSubTicket[z].Name,
name:'checklist',
inputValue:arrSubTicket[z].Id,
relatedTicket:arrSubTicket[z].TicketId
//any other checkbox properties, layout related or whatever
});
}
var myCheckboxGroup = Ext.create('Ext.form.CheckboxGroup', {
columns: 1,
vertical: true,
items: checkboxconfigs
});
myCheckboxGroup.on({
change: function(checkboxGroup, newValue) {
formattedValues = [];
newValue = newValue.checklist.length === 0 ? [newValue.checklist] : newValue.checklist;
checkboxGroup.items.each(function(checkbox){
var checkboxValue = checkbox.inputValue,
foramttedValue = {};
foramttedValue[checkboxValue] = newValue.indexOf(checkboxValue) !== -1 ? 'on' : 'off';
formattedValues.push(foramttedValue);
});
}
});
form = Ext.widget('form', {
layout: {
type: 'vbox',
align: 'stretch'
},
border: false,
bodyPadding: 10,
fieldDefaults: {
labelAlign: 'top',
labelWidth: 100,
labelStyle: 'font-weight:bold'
},
defaults: {
margins: '0 0 10 0'
},
items: [{
xtype: 'fieldcontainer',
labelStyle: 'font-weight:bold;padding:0',
layout: 'vbox',
defaultType: 'textfield',
fieldDefaults: {
labelAlign: 'left'
},
items: [
/*{
flex: 1,
name: 'Name',
fieldLabel: 'Ticket Description',
allowBlank: true
},*/
{
name: 'Hours',
fieldLabel: 'Hours',
allowBlank: true,
value: record.data.Hours
},
{
flex: 2,
xtype:'textarea',
name: 'Notes',
fieldLabel: 'Ticket Notes',
allowBlank: true
},
{
xtype: 'combo',
fieldLabel: 'Status',
hiddenName: 'Status',
allowBlank: false,
name:'Status',
store: new Ext.data.SimpleStore({
data: allstatus,
id: 0,
fields: ['value', 'text']
}),
// valueField: 'value',
valueField: 'value',
displayField: 'text',
triggerAction: 'all',
editable: false,
// value : record.data.Status
value : statusname
},
{
xtype: 'combo',
fieldLabel: 'Priority',
hiddenName: 'Priority',
allowBlank: false,
name:'Priority',
store: new Ext.data.SimpleStore({
data: priorities,
id: 0,
fields: ['value', 'text']
}),
// valueField: 'value',
valueField: 'value',
displayField: 'text',
triggerAction: 'all',
editable: false,
value : record.data.Priority
},
{
xtype: 'button',
id: 'newSubTicket',
cls:'x-btn-default-small',
text: '+ Checklist',
handler : function () {
createSubticket(record,statusname);
},
style : 'margin:0 0px'
},
myCheckboxGroup
]
}],
buttons: [{
text: 'Cancel',
handler: function() {
this.up('form').getForm().reset();
this.up('window').hide();
}
}, {
text: 'Save',
handler: function() {
if (this.up('form').getForm().isValid())
{
// In a real application, this would submit the form to the configured url
// this.up('form').getForm().submit();
form = this.up('form').getForm();
var recordsToAdd = [],recordsToAddNotes = [];
var record1 = {},recordNotes = {};
//this.up('window').hide();
//var summary = form.findField('Name').getSubmitValue();
var hrs = form.findField('Hours').getSubmitValue();
var status = form.findField('Status').getSubmitValue();
var priority = form.findField('Priority').getSubmitValue();
var notes = form.findField('Notes').getSubmitValue();
record1['ccfive_related_ticket_status']=status;
record1['dev_priority']=priority;
record1['io_uuid'] = record.data.Id;
//console.log("TicketName="+record.data.TicketName);
recordsToAdd.push(record1);
recordNotes['dev_note'] = notes;
recordNotes['dev_hours'] = hrs;
recordNotes['dev_related_punchlist_item'] = record.data.Id;
recordNotes['ccfive_related_ticket_status'] = status;
recordsToAddNotes.push(recordNotes);
}
}
}]
});
win = Ext.widget('window', {
title: record.data.TicketName,
closeAction: 'hide',
width: 400,
height: 450,
minHeight: 220,
layout: 'fit',
resizable: true,
modal: true,
items: form
});
win.show();
}
This is what I get on first call
But after clicking on cancel and calling the function it displays me.
Duplicate checkboxes and checklist button on second call
Move var checkboxconfigs = []; into showassetForm function
function showassetForm(record, statusname, emptyval) {
var checkboxconfigs = [];
var arrSubTicket = getSubTickets(record.data.Id);
The issue was just of passing id to some parameters on form.
Extjs sometimes behaves weird if Id is passed.
Removed id parameter and it worked fine!
Try and avoid duplicate ids (see comment "double check this"):
for(z=0;z<arrSubTicket.length;z++)
{
checkboxconfigs.push({
id:arrSubTicket[z].Id, // <==================== double check this!!
boxLabel:arrSubTicket[z].Name,
name:'checklist',
inputValue:arrSubTicket[z].Id, // <============ double check this!!
relatedTicket:arrSubTicket[z].TicketId
});
I having an issue with paging toolbar.
I want to give the user the option to set the no of results per page(limit). I have a drop-down for it.
I have initialised my page size as 20.
When i set my limit (e.g. 50) from dropdown, n suppose i get 90 results, so on the first page it is showing correctly from 1-50 results but on the next page its showing results from 21-70 instead of 51-90.
So i am not able to reset my page size according to limit set by the dropdown. the start is always picking up the initialised page size.
Any suggestions?
I am attaching my code...
linkCheckerUI = {
pageSize: 20,
test:null,
getPanel: function(config) {
var fields = ["path","jcrObject","type","URL","response"];
var rootpath = null;
var term= null;
var end=null;
var internal_links=null;
var external_links=null;
var smart_links=null;
var videoid_links=null;
this.store = new CQ.Ext.data.Store({
proxy: new CQ.Ext.data.HttpProxy({
url: '/bin/linkchecker',
method: 'GET'
}),
reader: new CQ.Ext.data.JsonReader({
"root": "data",
"fields": fields,
"idProperty":'jcrObject',
totalProperty: 'results'
}),
baseParams: { searchterm: term,startpath: rootpath, endpath: end,
internal: internal_links,external: external_links,smart: smart_links,videoid: videoid_links}
});
test=this.store;
this.store.on('beforeload',function(store, operation,eOpts){
limit= CQ.Ext.getCmp('limit').getRawValue();
limit = (limit=="") ? 15 : limit;
pageSize = limit;
start=operation.params.start;
start = (start==null) ? 0 : start;
searchterm = CQ.Ext.getCmp('searchterm').getValue();
startpath = CQ.Ext.getCmp('startpath').getValue();
endpath = CQ.Ext.getCmp('endpath').getValue();
internal = CQ.Ext.getCmp('internal').getValue();
external = CQ.Ext.getCmp('external').getValue();
smart = CQ.Ext.getCmp('smart').getValue();
videoid = CQ.Ext.getCmp('videoid').getValue();
ebroken = CQ.Ext.getCmp('excludebroken').getValue();
ehealthy= CQ.Ext.getCmp('excludehealthy').getValue();
alert(start);
operation.params={
searchterm: searchterm ,startpath: startpath , endpath: endpath ,
internal: internal ,external: external,smart: smart,videoid: videoid,start:start,
limit:limit,ebroken: ebroken,ehealthy: ehealthy
};},this);
this.loadGrid();
this.loadForm();
// create main panel
this.panel = new CQ.Ext.Panel({
region: 'center',
layout: 'border',
margins: '5 5 5 5',
height:'100%',
border: false,
items: [this.form,this.grid]
});
// load grid data
this.reload();
// return outer panel
return this.panel;
},
/**
* Load form
*/
loadForm: function() {
var searchterm = null;
this.form = new CQ.Ext.form.FormPanel({
region: "north",
title: "Link Control Center",
width: 220,
top: 50,
height:350,
collapsible: false,
split: true,
parent: this,
padding:'10px',
items: [
{
xtype: 'textfield',
name: 'searchterm',
id: 'searchterm',
fieldLabel:'Search Term',
emptyText:'Please enter a search term',
width: 583
},
{
xtype: 'pathfield',
name: 'startpath',
id: 'startpath',
fieldLabel: 'Start Path',
allowBlank: false,
width: 600
},
{
xtype: 'pathfield',
name: 'endpath',
id: 'endpath',
fieldLabel: 'End Path',
width: 600
},
{
xtype: 'combo',
name: 'limit',
id:'limit',
fieldLabel: 'Result Display',
emptyText:'Select # results per page',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
store: [['val1','15'],['val2','100'],['val3','500'],['val4','1000'],['val5','All']]
},
{
fieldLabel: 'Link Type',
xtype: 'checkbox',
boxLabel: 'Internal',
checked : true,
name: 'internal',
id:'internal'
},
{
xtype: 'checkbox',
boxLabel: 'External',
checked : true,
name: 'external',
id:'external'
},
{
xtype: 'checkbox',
boxLabel: 'SMART',
checked : true,
name: 'smart',
id:'smart'
},
{
xtype: 'checkbox',
boxLabel: 'Video (Asset ID)',
checked : true,
name: 'videoid',
id: 'videoid'
},
{
fieldLabel: 'Exclude',
xtype: 'checkbox',
boxLabel: 'Exclude broken links',
name: 'excludebroken',
id:'excludebroken'
},
{
xtype: 'checkbox',
boxLabel: 'Exclude healthy links',
name: 'excludehealthy',
id: 'excludehealthy'
}
],
buttons:[{
text: 'Submit',
handler: function() {
searchterm = CQ.Ext.getCmp('searchterm').getValue();
startpath = CQ.Ext.getCmp('startpath').getValue();
endpath = CQ.Ext.getCmp('endpath').getValue();
internal = CQ.Ext.getCmp('internal').getValue();
external = CQ.Ext.getCmp('external').getValue();
smart = CQ.Ext.getCmp('smart').getValue();
videoid = CQ.Ext.getCmp('videoid').getValue();
limit = CQ.Ext.getCmp('limit').getRawValue();
pageSize=15;
alert("2");
test.clearFilter(false);
if(startpath){
if (endpath.substring(0, startpath.length) == startpath || endpath=="")
{
test.load();
}
else
{
alert('Specified End Path is not within Start Path node!\nSelect an End Path within and below Start Path hierarchy node');
}
}
else{
alert('Fill in all required fields before submitting the query');
}
}
}
]
});
},
/**
* Load grid
*/
loadGrid: function() {
// export to CSV button
this.exportCSVButton = new CQ.Ext.Button({iconCls: 'icon-csv', text: 'Export as CSV'});
this.exportCSVButton.setHandler(function() {
searchterm = CQ.Ext.getCmp('searchterm').getValue();
startpath = CQ.Ext.getCmp('startpath').getValue();
endpath = CQ.Ext.getCmp('endpath').getValue();
internal = CQ.Ext.getCmp('internal').getValue();
external = CQ.Ext.getCmp('external').getValue();
smart = CQ.Ext.getCmp('smart').getValue();
videoid = CQ.Ext.getCmp('videoid').getValue();
ebroken = CQ.Ext.getCmp('excludebroken').getValue();
ehealthy= CQ.Ext.getCmp('excludehealthy').getValue();
var url = "/bin/linkchecker.csv?searchterm="+searchterm +"&startpath="+startpath +"&endpath="+endpath+ "&internal="+internal +"&external="+external+
"&smart="+smart+"&videoid"+videoid+"&ebroken="+ebroken +"&ehealthy="+ehealthy+"&start=0&limit=-1" ;
window.location=(url);
}, this);
var body = CQ.Ext.getBody();
this.grid = new CQ.Ext.grid.GridPanel({
region: "center",
border:false,
store: this.store,
//parent:this,
loadMask: new CQ.Ext.LoadMask(body, {msg: 'Loading please wait...'}),
tbar: ['Result List',
'->', this.exportCSVButton
],
columns: [
{header: "Path", width: 80,dataIndex: 'path', sortable: true},
{header: "JCR Object Node", width: 80,dataIndex: 'jcrObject', sortable: true},
{header: "Type", width: 15, dataIndex: 'type', sortable: true},
{header: "URL", width: 70, dataIndex: 'URL', sortable: true},
{header: "Error Type", width:15, dataIndex: 'response', sortable: true,
renderer: function(value){ if (value =='200')return '<span style="color:green;">'+value+'</span>'; else return '<span style="color:red;">'+value+'</span>';}}
],
renderTo:this.grid,
stripeRows: true,
viewConfig: {
forceFit: true
},
bbar: new CQ.Ext.PagingToolbar({
store: this.store,
pageSize:this.pageSize,
displayInfo: true
}),
sm: new CQ.Ext.grid.RowSelectionModel({singleSelect:true}),
iconCls:'icon-grid'
});
alert("3");
this.grid.loadMask.show();
},
/**
* Reload grid data (reset to first page)
*/
reload: function() {
alert("4");
this.store.load({ baseParams: {start: 0, limit: this.pageSize}});
}
}
Try using extraParams on the store.
this.store.getProxy().extraParams = { start: 0, limit: this.pageSize};
this.store.load();
i have a problem with this example see this link
http://dev.sencha.com/deploy/ext-4.0.0/examples/grid/buffer-grid.html
i want to convert in MVC application. So anybody please help me .
Firstly your model in your app/model folder
Ext.define('AppName.model.Employee', {
extend: 'Ext.data.Model',
fields: [
{name: 'rating', type: 'int'},
{name: 'salary', type: 'float'},
{name: 'name'}
]
});
and store in your app/store folder
Ext.define('AppName.store.Employee', {
extend:'Ext.data.Store',
buffered: true,
pageSize: 5000,
model: 'Employee',
proxy: { type: 'memory' }
});
And your grid view in your app/view folder
Ext.define('AppName.view.EmployeeGrid', {
alias:'employeegrid',
extend:'Ext.grid.Panel',
width: 700,
height: 500,
title: 'Bufffered Grid of 5,000 random records',
store: 'Employee',
loadMask: true,
disableSelection: true,
viewConfig: { trackOver: false },
columns:[{
xtype: 'rownumberer',
width: 40,
sortable: false
},{
text: 'Name',
flex:1 ,
sortable: true,
dataIndex: 'name'
},{
text: 'Rating',
width: 125,
sortable: true,
dataIndex: 'rating'
},{
text: 'Salary',
width: 125,
sortable: true,
dataIndex: 'salary',
align: 'right',
renderer: Ext.util.Format.usMoney
}]
});
And your controller in your app/controller folder
Ext.define('AppName.controller.Employee',{
extend:'Ext.app.Controller',
stores:['Employee'],
views:['EmployeeGrid'],
refs:[
{ref:'employeeGrid',selector:'employeegrid'}
],
init:function(){
var me = this;
me.getEmployeeStore().loadData(me.createFakeData(5000));
},
createFakeData:function(count) {
var firstNames = ['Ed', 'Tommy', 'Aaron', 'Abe', 'Jamie', 'Adam', 'Dave', 'David', 'Jay', 'Nicolas', 'Nige'],
lastNames = ['Spencer', 'Maintz', 'Conran', 'Elias', 'Avins', 'Mishcon', 'Kaneda', 'Davis', 'Robinson', 'Ferrero', 'White'],
ratings = [1, 2, 3, 4, 5],
salaries = [100, 400, 900, 1500, 1000000];
var data = [];
for (var i = 0; i < (count || 25); i++) {
var ratingId = Math.floor(Math.random() * ratings.length),
salaryId = Math.floor(Math.random() * salaries.length),
firstNameId = Math.floor(Math.random() * firstNames.length),
lastNameId = Math.floor(Math.random() * lastNames.length),
rating = ratings[ratingId],
salary = salaries[salaryId],
name = Ext.String.format("{0} {1}", firstNames[firstNameId], lastNames[lastNameId]);
data.push({
rating: rating,
salary: salary,
name: name
});
}
return data;
}
});
Funally u have to create App in your app folder
Ext.application({
requires:[
'Ext.grid.*',
'Ext.data.*',
'Ext.util.*',
'Ext.grid.PagingScroller',
'AppName.view.EmployeeGrid'
],
name:'AppName',
models:['Employee'],
stores:['Employee'],
controllers:['Employee'],
launch:function () {
Ext.onReady(function(){
Ext.create('Ext.Viewport', {
layout: 'fit',
items:[{xtype:'emplyeegrid'}]
});
});
}
});
I'm trying to get an ExtJS grid working that has checkboxes from which I can get an array of rows/ids so I know which rows have been checked.
I've used this example from Sencha to get the following grid to display correctly with the selection checkboxes, but it doesn't show how to get the information from the grid which rows have been checked, e.g. I will have a button that has a handler function and inside this I need to write something like:
var rowIdsChecks = grid.getRowIdsChecked();
How do I get the information out of the grid which rows are currently checked?
var myData = [
[4, 'This is a whole bunch of text that is going to be word-wrapped inside this column.', 0.24, '2010-11-17 08:31:12'],
[16, 'Computer2', 0.28, '2010-11-14 08:31:12'],
[5, 'Network1', 0.02, '2010-11-12 08:31:12'],
[1, 'Network2', 0.01, '2010-11-11 08:31:12'],
[12, 'Other', 0.42, '2010-11-04 08:31:12']
];
var myReader = new Ext.data.ArrayReader({}, [{
name: 'id',
type: 'int'
}, {
name: 'object',
type: 'object'
}, {
name: 'status',
type: 'float'
}, {
name: 'lastChange',
type: 'date',
dateFormat: 'Y-m-d H:i:s'
}]);
var sm = new Ext.grid.CheckboxSelectionModel();
var grid = new Ext.grid.GridPanel({
region: 'center',
style: 'margin: 10px',
store: new Ext.data.Store({
data: myData,
reader: myReader
}),
cm: new Ext.grid.ColumnModel({
defaults: {
width: 120,
sortable: true
},
columns: [
sm,
{
header: 'ID',
width: 50,
sortable: true,
dataIndex: 'id',
hidden: false
},
{
header: 'Object',
width: 120,
sortable: true,
dataIndex: 'object',
renderer: columnWrap
}, {
header: 'Status',
width: 90,
sortable: true,
dataIndex: 'status'
},
{
header: 'Last Updated',
width: 120,
sortable: true,
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
dataIndex: 'lastChange'
}]
}),
sm: sm,
viewConfig: {
forceFit: true
},
title: 'Computer Information',
width: 500,
autoHeight: true,
frame: true,
listeners: {
'rowdblclick': function(grid, index, rec){
var id = grid.getSelectionModel().getSelected().json[0];
go_to_page('edit_item', 'id=' + id);
}
}
});
Solution:
Thanks #jujule, this code works:
Ext.select('span#internal_link_001').on('click', function() {
var selections = grid.getSelectionModel().getSelections();
console.log(selections);
});
and then you have the ids like this:
The CheckboxSelectionModel is responsible of tracking and managing selections.
Just use its getSelections() method to get an array of selected records :
grid.getSelectionModel().getSelections()
If the grid has been loaded say a , then use.
<script type="text/javascript" language="javascript">
function ValidateCheckBoxChecked() {
var count = 0;
var counter = 0;
var ChkBoxValue;
var checkboxList = document.getElementById("divGridData").getElementsByTagName("input");
for (var i = 0; i < checkboxList.length; i++) {
if (checkboxList[i].checked) {
counter++;
}
}
return counter; //this will return the number of checkBoxed checked.
}
</script>