How to edit cell in grid panel in Ext JS 3.4? - extjs

Is it possible to make cell editable in ext js 3.4 gridpanel?
If yes please reply me how?
This is the code I tried,
var fm = Ext.form;
var grid = new Ext.grid.EditorGridPanel({
height: 500,
renderTo: Ext.getBody(),
width: 800,
loadMask: false,
viewConfig: {
emptyText: 'No data to display'
},
selModel: checkboxselection,
tbar: mainGridToolbar,
clicksToEdit: 1,
store: cartStore,
listeners: {
afteredit: function(o) {
var pos = o.record.get('POS');
var quantity = o.value;
}
},
columns: [
checkboxselection,
{
header: "quantity",
align: 'right',
dataIndex: 'QUANTITY',
sortable: true,
editor: new fm.TextField({
allowBlank: false
})
}
]
});

Edit
You are missing the plugin line... (I never heard of a EditorGridPanel, but I am on 4.x and may be mistaken at this point)
plugins: new Ext.ux.grid.RowEditor({saveText: 'Update'});
Origin
Use the Row Editor Plugin for these. You can specify for each cell if it should be editable or not.
You should really take look at the examples that comes along with the library! These lines can be found under ext-3.4.0\examples\grid\row-editor.js
Ext.onReady(function(){
Ext.QuickTips.init();
var Employee = Ext.data.Record.create([{
name: 'name',
type: 'string'
}, {
name: 'email',
type: 'string'
}, {
name: 'start',
type: 'date',
dateFormat: 'n/j/Y'
},{
name: 'salary',
type: 'float'
},{
name: 'active',
type: 'bool'
}]);
// hideous function to generate employee data
var genData = function(){
var data = [];
var s = new Date(2007, 0, 1);
var now = new Date(), i = -1;
while(s.getTime() < now.getTime()){
var ecount = Ext.ux.getRandomInt(0, 3);
for(var i = 0; i < ecount; i++){
var name = Ext.ux.generateName();
data.push({
start : s.clearTime(true).add(Date.DAY, Ext.ux.getRandomInt(0, 27)),
name : name,
email: name.toLowerCase().replace(' ', '.') + '#exttest.com',
active: true,
salary: Math.floor(Ext.ux.getRandomInt(35000, 85000)/1000)*1000
});
}
s = s.add(Date.MONTH, 1);
}
return data;
}
var store = new Ext.data.GroupingStore({
reader: new Ext.data.JsonReader({fields: Employee}),
data: genData(),
sortInfo: {field: 'start', direction: 'ASC'}
});
var editor = new Ext.ux.grid.RowEditor({
saveText: 'Update'
});
var grid = new Ext.grid.GridPanel({
store: store,
width: 600,
region:'center',
margins: '0 5 5 5',
autoExpandColumn: 'name',
plugins: [editor],
view: new Ext.grid.GroupingView({
markDirty: false
}),
tbar: [{
iconCls: 'icon-user-add',
text: 'Add Employee',
handler: function(){
var e = new Employee({
name: 'New Guy',
email: 'new#exttest.com',
start: (new Date()).clearTime(),
salary: 50000,
active: true
});
editor.stopEditing();
store.insert(0, e);
grid.getView().refresh();
grid.getSelectionModel().selectRow(0);
editor.startEditing(0);
}
},{
ref: '../removeBtn',
iconCls: 'icon-user-delete',
text: 'Remove Employee',
disabled: true,
handler: function(){
editor.stopEditing();
var s = grid.getSelectionModel().getSelections();
for(var i = 0, r; r = s[i]; i++){
store.remove(r);
}
}
}],
columns: [
new Ext.grid.RowNumberer(),
{
id: 'name',
header: 'First Name',
dataIndex: 'name',
width: 220,
sortable: true,
editor: {
xtype: 'textfield',
allowBlank: false
}
},{
header: 'Email',
dataIndex: 'email',
width: 150,
sortable: true,
editor: {
xtype: 'textfield',
allowBlank: false,
vtype: 'email'
}
},{
xtype: 'datecolumn',
header: 'Start Date',
dataIndex: 'start',
format: 'm/d/Y',
width: 100,
sortable: true,
groupRenderer: Ext.util.Format.dateRenderer('M y'),
editor: {
xtype: 'datefield',
allowBlank: false,
minValue: '01/01/2006',
minText: 'Can\'t have a start date before the company existed!',
maxValue: (new Date()).format('m/d/Y')
}
},{
xtype: 'numbercolumn',
header: 'Salary',
dataIndex: 'salary',
format: '$0,0.00',
width: 100,
sortable: true,
editor: {
xtype: 'numberfield',
allowBlank: false,
minValue: 1,
maxValue: 150000
}
},{
xtype: 'booleancolumn',
header: 'Active',
dataIndex: 'active',
align: 'center',
width: 50,
trueText: 'Yes',
falseText: 'No',
editor: {
xtype: 'checkbox'
}
}]
});
var cstore = new Ext.data.JsonStore({
fields:['month', 'employees', 'salary'],
data:[],
refreshData: function(){
var o = {}, data = [];
var s = new Date(2007, 0, 1);
var now = new Date(), i = -1;
while(s.getTime() < now.getTime()){
var m = {
month: s.format('M y'),
employees: 0,
salary: 0,
index: ++i
}
data.push(m);
o[m.month] = m;
s = s.add(Date.MONTH, 1);
}
store.each(function(r){
var m = o[r.data.start.format('M y')];
for(var i = m.index, mo; mo = data[i]; i++){
mo.employees += 10000;
mo.salary += r.data.salary;
}
});
this.loadData(data);
}
});
cstore.refreshData();
store.on('add', cstore.refreshData, cstore);
store.on('remove', cstore.refreshData, cstore);
store.on('update', cstore.refreshData, cstore);
var chart = new Ext.Panel({
width:600,
height:200,
layout:'fit',
margins: '5 5 0',
region: 'north',
split: true,
minHeight: 100,
maxHeight: 500,
items: {
xtype: 'columnchart',
store: cstore,
url:'../../resources/charts.swf',
xField: 'month',
yAxis: new Ext.chart.NumericAxis({
displayName: 'Employees',
labelRenderer : Ext.util.Format.numberRenderer('0,0')
}),
tipRenderer : function(chart, record, index, series){
if(series.yField == 'salary'){
return Ext.util.Format.number(record.data.salary, '$0,0') + ' total salary in ' + record.data.month;
}else{
return Ext.util.Format.number(Math.floor(record.data.employees/10000), '0,0') + ' total employees in ' + record.data.month;
}
},
// style chart so it looks pretty
chartStyle: {
padding: 10,
animationEnabled: true,
font: {
name: 'Tahoma',
color: 0x444444,
size: 11
},
dataTip: {
padding: 5,
border: {
color: 0x99bbe8,
size:1
},
background: {
color: 0xDAE7F6,
alpha: .9
},
font: {
name: 'Tahoma',
color: 0x15428B,
size: 10,
bold: true
}
},
xAxis: {
color: 0x69aBc8,
majorTicks: {color: 0x69aBc8, length: 4},
minorTicks: {color: 0x69aBc8, length: 2},
majorGridLines: {size: 1, color: 0xeeeeee}
},
yAxis: {
color: 0x69aBc8,
majorTicks: {color: 0x69aBc8, length: 4},
minorTicks: {color: 0x69aBc8, length: 2},
majorGridLines: {size: 1, color: 0xdfe8f6}
}
},
series: [{
type: 'column',
displayName: 'Salary',
yField: 'salary',
style: {
image:'../chart/bar.gif',
mode: 'stretch',
color:0x99BBE8
}
}]
}
});
var layout = new Ext.Panel({
title: 'Employee Salary by Month',
layout: 'border',
layoutConfig: {
columns: 1
},
width:600,
height: 600,
items: [chart, grid]
});
layout.render(Ext.getBody());
grid.getSelectionModel().on('selectionchange', function(sm){
grid.removeBtn.setDisabled(sm.getCount() < 1);
});
});

Related

How to pass parameter value from view to Ext.window?

I am get confused to pass value from view to window,
I have a view contain the user info and one button on which click a new window opens to upload an Image file. the image upload code I done in window. But I want to pass User Id with the image which I want to post on server. the user Id I on View. I want to carry that userId on file upload window. How can I do this?
Bellow is my code.
file upload view
Ext.define('vDemo.view.FileUpload', {
extend: 'Ext.Panel',
region: 'center',
border:'false',
initComponent: function () {
var me = this;
this.form = new Ext.form.Panel({
xtype: 'panel',
border: false,
//layout: 'vbox',
padding: '2 2 2 2',
bodyPadding: 10,
frame: false,
renderTo: Ext.getBody(),
items: [{
xtype: 'filefield',
name: 'photo',
fieldLabel: 'Photo',
labelWidth: 50,
msgTarget: 'side',
allowBlank: false,
anchor: '100%',
buttonText: 'Select Photo...'
}],
buttons: [{
text: 'Upload',
handler: function () {
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
url: 'photo-upload.php',
waitMsg: 'Uploading your photo...',
success: function (fp, o) {
Ext.Msg.alert('Success', 'Your photo "' + o.result.file + '" has been uploaded.');
}
});
}
}
}]
});
this.items = [this.form];
this.callParent();
}
});
UserForm view (on which button click I am open the file upload window)
Ext.define('vDemo.view.userHome', {
extend: 'Ext.Panel',
border: false,
Padding: '5 5 5 5',
title: 'Home',
initComponent: function () {
var me = this;
this.changingImage = Ext.create('Ext.Img', {
src:'', //'appRes/ProfilePic/ProfilePic1.png',
width: 150,
height: 170
});
this.image = new Ext.Container({
cls: 'img-block',
padding:'0 0 2 0',
items: [this.changingImage]
});
this.ImagePanel = new Ext.form.Panel({
padding: '5 5 5 5',
layout: 'vbox',
border: false,
items: [
this.image,
{
xtype: 'button',
text: 'Chage Image',
width: 150,
height: 30,
handler: function () {
me.fileUpload();
}
}
]
});
this.InfoPanel = new Ext.form.Panel({
padding: '5 5 5 5',
layout: 'vbox',
border: false,
items: [{
xtype: 'hidden',
name: 'hfUserAutoId'
},
{
xtype: 'displayfield',
fieldLabel: 'Name:',
name: 'lblName',
value: ''
},
{
xtype: 'displayfield',
fieldLabel: 'Email:',
name: 'lblEmail',
value: ''
},
{
xtype: 'displayfield',
fieldLabel: 'Date of Birth:',
name: 'lblDateOfBirth',
value: ''
},
{
xtype: 'displayfield',
fieldLabel: 'UserId',
name: 'lblUserId',
value: ''
},
{
xtype: 'displayfield',
fieldLabel: 'Gender',
name: 'lblGender',
value: ''
},
{
xtype: 'displayfield',
fieldLabel: 'Blood Group',
name: 'lblBloodGroup',
value: ''
},
{
xtype: 'displayfield',
fieldLabel: 'Hieght',
name: 'lblHieght',
value: ''
}]
});
this.form = new Ext.form.Panel({
padding: '10 100 10 100',
layout: 'hbox',
header: {
titlePosition: 0,
items: [{
xtype: 'button',
text: 'Back',
handler: function () {
me.fireEvent('getBack');
}
}]
},
items: [me.ImagePanel, this.InfoPanel]
});
this.items = [this.form];
this.callParent();
},
fillForm: function(sRec) {
var me = this;
console.log(sRec);
// var sRec1 = Ext.StoreMgr.lookup('UserInfo').getById(ssRec.get('userAutoId'));
console.log(sRec[0].userAutoId);
me.form.getForm().findField('hfUserAutoId').setValue(sRec.userAutoId);
me.form.getForm().findField('lblName').setValue(sRec[0].firstName + " " + sRec[0].lastName);
me.form.getForm().findField('lblUserId').setValue(sRec[0].userid);
me.form.getForm().findField('lblEmail').setValue(sRec[0].email);
if (sRec[0].gender == true) {
me.form.getForm().findField('lblGender').setValue("Male");
}
else if (sRec[0].gender == false) {
me.form.getForm().findField('gender').setValue("Female");
};
me.form.getForm().findField('lblDateOfBirth').setValue(sRec[0].DOB);
me.form.getForm().findField('lblBloodGroup').setValue(sRec[0].bloodGroup);
me.form.getForm().findField('lblHieght').setValue(sRec[0].hieght);
// me.form.getForm().findField('image').setSrc(sRec.get('profilePicPath'));
me.changingImage.setSrc(sRec[0].profilePicPath);
},
fileUpload: function () {
this.uploadWinPanel = new vDemo.view.FileUpload({});
var hfUserAutoId = me.form.getForm().findField('hfUserAutoId').getValue();
this.EditWin = new Ext.Window({
//header:false,
Height: 400,
width: 320,
title: 'Upload Photo',
border: 0,
resizable: false,
draggable: false,
modal: false,
items: [this.uploadWinPanel]
}).show();
}
});
Well, you pass the user id on initialization of the uploadWinPanel like so:
var hfUserAutoId = me.form.getForm().findField('hfUserAutoId').getValue();
this.uploadWinPanel = new vDemo.view.FileUpload({
userId: hfUserAutoId
});
And then in the FileUpload component, beside the filefield, you add a hiddenfield which grabs the userId value:
items: [{
xtype: 'filefield',
name: 'photo',
fieldLabel: 'Photo',
labelWidth: 50,
msgTarget: 'side',
allowBlank: false,
anchor: '100%',
buttonText: 'Select Photo...'
},{
xtype: 'hiddenfield',
name: 'user_id',
value: this.userId
}]

extjs subtable checkcolumn click

I am very new to extjs, and I saw this excellent post:
dynamic url inside a extjs table dont work
I was wondering if there is a way to enable checkbox functionality on the subtable?
I tried making slight modifications to the sample, but I can't find a way to have the checkboxes clickable and capture the events associated with it.
Please see the modified code below. Is it possible to have a clickable checkbox inside a Subtable?
Thanks in advance!
// SALVAGUARDAS -- added Approved field
Ext.define('Salvaguardas', {
extend: 'Ext.data.Model',
fields: ['Approved', 'id_amenaza', 'tipo', 'modo', 'codigo', 'denominacion', 'eficiencia', ]
});
//SALVAGUARDAS
var salvaguardaStore = Ext.create('Ext.data.Store', {
model: 'Salvaguardas',
data: [
{Approved: true, id_amenaza: 1, tipo: 'Correctiva', modo: 'Correctiva', codigo: 'corr-01', denominacion: 'correctiva 1', eficiencia: 'MB' }
]
});
//GRIDPANEL
Ext.create('Ext.grid.Panel', {
renderTo: 'example-grid',
store: amenazaStore,
//width: 748,
//height: 598,
title: '<bean:write name="informesAGRForm" property="nombreActivo"/>',
plugins: [{
ptype: "subtable",
headerWidth: 24,
listeners: {
'rowdblclick': function(grid, rowIndex, columnIndex, e){
// Get the Record, this is the point at which rowIndex references a
// record's index in the grid's store.
var record = grid.getStore().getAt(rowIndex);
// Get field name
var fieldName = grid.getColumnModel().getDataIndex(columnIndex);
var data = record.get(fieldName);
alert(data);
}
},
columns: [{
//text: 'Approved',
//dataIndex: 'Approved',
//hidden: true,
//width: 100
xtype: 'checkcolumn',
header: 'Approved',
dataIndex: 'Approved',
width: 85,
listeners: {
checkChange: function ()
{
console.log('checkChange');
}
}
}, {
text: 'id_amenaza',
dataIndex: 'id_amenaza',
hidden: true,
width: 100
}, {
width: 100,
text: 'id_salvaguarda',
dataIndex: 'id_salvaguarda'
},
{
text: 'denominacion',
dataIndex: 'denominacion',
width: 100
},{
text: 'descripcion',
dataIndex: 'descripcion',
width: 100
},{
text: 'eficacia',
dataIndex: 'eficacia',
width: 100
},
],
getAssociatedRecords: function (record) {
var result = Ext.Array.filter(
salvaguardaStore.data.items,
function (r) {
return r.get('id_amenaza') == record.get('id');
});
return result;
}
}],
listeners: {
rowdblclick: function (view, record, tr, columnIndex, e) {
console.log('rowdblclick');
var cell = e.getTarget('.x-grid-subtable-cell');
if (!cell) {
return;
}
var row = Ext.get(cell).up('tr');
var tbody = row.up('tbody');
var rowIdx = tbody.query('tr', true).indexOf(row.dom);
//var records = view.up('grid').getPlugin('subtable').getAssociatedRecords(record);
var records = view.up('grid').plugins[0].getAssociatedRecords(record);
var subRecord = records[rowIdx];
console.log('rowdblclick: ' + rowIdx + ' - ' + subRecord);
},
rowclick: function (view, record, tr, columnIndex, e) {
console.log('rowclick');
var cell = e.getTarget('.x-grid-subtable-cell');
if (!cell) {
return;
}
var row = Ext.get(cell).up('tr');
var tbody = row.up('tbody');
var rowIdx = tbody.query('tr', true).indexOf(row.dom);
//var records = view.up('grid').getPlugin('subtable').getAssociatedRecords(record);
var records = view.up('grid').plugins[0].getAssociatedRecords(record);
var subRecord = records[rowIdx];
console.log('rowclick: ' + rowIdx + ' - ' + subRecord);
}
},
collapsible: false,
animCollapse: false,
columns: [
{
text: 'ID',
hidden: true,
hideable: false,
dataIndex: 'id'
},
{
text: 'Codigo',
width: 50,
sortable: true,
hideable: false,
dataIndex: 'codigo'
},
{
text: 'DenominaciĆ³n',
width: 150,
dataIndex: 'denominacion',
},
{
text: ' Autenticidad',
flex: 1,
dataIndex: 'a_riesgo'
},
{
text: 'Confidencialidad',
flex: 1,
dataIndex: 'c_riesgo'
},
{
text: 'Integridad',
flex: 1,
dataIndex: 'i_riesgo'
},
{
text: 'Disponibilidad',
flex: 1,
dataIndex: 'd_riesgo'
},
{
text: 'Trazabilidad',
flex: 1,
dataIndex: 't_riesgo'
},
{
text: 'Total',
flex: 1,
dataIndex: 'total_riesgo'
}]
});

Concatenate in EditorGridPanel

Inside of my editorGridPanel, I have a three columns. I want to concatenate the data inside of my 'firstname' and 'lastname' column directly going to or when the cursor or focus are now in my 'email address' column in every row. Could someone help me about this problem?
var cm = new Ext.grid.ColumnModel({
defaults: {
sortable: true
},
columns: [{
id: 'id',
header: 'ID',
dataIndex: 'id',
width: 220,
editable: false,
hidden: true
},
{
id: 'firstname',
header: 'First Name',
dataIndex: 'firstname',
width: 220,
editor: new fm.TextField({
allowBlank: false
}),
listeners: {
click: function(){
Ext.getCmp('b_save').enable();
Ext.getCmp('b_cancel').enable();
}
}
},
{
id: 'lastname',
header: 'Last Name',
dataIndex: 'lastname',
width: 220,
align: 'left',
editor: new fm.TextField({
allowBlank: false
}),
listeners: {
click: function(){
Ext.getCmp('b_save').enable();
Ext.getCmp('b_cancel').enable();
}
}
},
{
id: 'email_address',
header: 'Email Address',
dataIndex: 'email_address',
width: 330,
align: 'left',
editor: new fm.TextField({
allowBlank: false
}),
listeners: {
click: function(){
Ext.getCmp('b_save').enable();
Ext.getCmp('b_cancel').enable();
}
}
},
var grid = new Ext.grid.EditorGridPanel({
viewConfig: {
forceFit: true,
autoFill: true
},
id: 'maingrid',
store: store,
cm: cm,
width: 700,
anchor: '100%',
height: 700,
frame: true,
loadMask: true,
waitMsg: 'Loading...',
clicksToEdit: 2,
sm : new Ext.grid.RowSelectionModel({
singleSelect: true
,onEditorKey : function(field, e) {
if (e.getKey() == e.ENTER) {
var k = e.getKey(), newCell, g = this.grid,ed = g.activeEditor || g.lastActiveEditor;
e.stopEvent();
/*ed.completeEdit();*/
if(e.shiftKey){
newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
}else{
newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
}
if(newCell){
g.startEditing(newCell[0], newCell[1]);
}
}
else if(e.getKey() == e.TAB){
var k = e.getKey(), newCell, g = this.grid,ed = g.activeEditor || g.lastActiveEditor;
e.stopEvent();
newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
if(newCell){
g.startEditing(newCell[0], newCell[1]);
}
}
}
}),
});
You can add concatenated firstname and lastname and set it as value into your email_address field in listener for beforeedit editorgrid event:
listeners: {
beforeedit: function(e) {
if (e.field === 'email_address' && e.value === '') {
var newValue = e.record.get('firstname') + '.' + e.record.get('lastname');
e.record.set('email_address', newValue);
}
}
},
Fiddle with example: https://fiddle.sencha.com/#fiddle/3mf

Extjs paging toolbar: not able to set start

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

Need to convert ExtJs sample app to MVC application

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

Resources