Ext.plugin.ListPaging - common 'load more...' issue - extjs

I'm dealing with the following problem, I got the below code:
VIEW:
Ext.define('aBMin.view.Email', {
extend : 'Ext.Panel',
alias : 'widget.email-panel',
config : {
layout : "fit",
items : [{
xtype : 'toolbar',
ui : 'light',
layout : 'hbox',
docked : 'top',
items : [{
xtype : 'searchfield',
name : 'emailsearch',
width: '45%',
flex : 1
}, {
xtype : 'selectfield',
flex : 2,
name : 'emailassign',
value : 'unassigned',
options : [{
text : 'All',
value : 'all'
}, {
text : 'Assigned',
value : 'assigned'
}, {
text : 'Unassigned',
value : 'unassigned'
}]
}]
}, {
xtype : 'list',
action : 'readEmail',
itemTpl : '<tpl for="."><div class="list-pos-row"><div class="list-pos-col">{emailsubject}</div></div><div class="list-pos-row"><div class="list-pos-col list-email-date">{emaildate}</div></div><div class="list-pos-row"><div class="list-pos-col list-email-from">{emailfrom}</div></div></tpl>',
itemSelector : 'div.contact',
emptyText : 'No data found.',
onItemDisclosure : true,
store : 'Email',
plugins : [{
xclass : 'Ext.plugin.ListPaging',
autoPaging : true,
noMoreRecordsText: 'No More Records'
}],
}]
}
});
STORE:
Ext.define('aBMin.store.Email', {
extend : 'Ext.data.Store',
requires : ['aBMin.model.Email'],
config : {
autoLoad : true,
model : 'aBMin.model.Email',
remoteFilter : true,
proxy : {
type : 'direct',
extraParams : {
filter : 'unassigned'
},
directFn : ClientemailTable.getListMobile,
config : {
paramsAsHash : true,
reader : {
type : 'json',
rootProperty : 'records'
,totalCount: 'totalCount'
}
}
}
}
});
MODEL
Ext.define('aBMin.model.Email', {
extend : 'Ext.data.Model',
config : {
fields : [{
name : 'clientemailid',
type : 'int'
}, {
name : 'clientid',
type : 'int'
},{
name : 'emailsubject',
type : 'string'
}, {
name : 'emailfrom',
type : 'string'
}, {
name : 'emailbody',
type : 'string'
}, {
name : 'supportstaffid',
type : 'int'
}, {
name : 'ticketid',
type : 'int'
}, {
name : 'emaildate',
type : 'string'
}, {
name : 'isassigned',
type : 'int'
}, {
name : 'newemailnote',
type : 'string'
}],
idProperty : 'clientemailid',
proxy : {
type : 'direct',
reader : {
type : 'json'
},
api : {
read : Clientemail.readMobile,
update : Clientemail.updateMobile
}
}
}
});
now... my service returns the following JSON response:
it's returned when the app send for ex. a request with a below like params:
and still... the 'load more', won't disapear.
So I guess what I'm trying to achieve is to get rid the 'load more...' button when the store is fully loaded. I've read few other topics on StackOverflow but didn't solve the thing.
Any comments / hins appreciated.

Key should be totalProperty in reader configuration, not totalCount.
http://docs.sencha.com/touch/2.2.1/#!/api/Ext.data.reader.Reader

Related

how do roweditor in Ext.create("Ext.window.Window") by extjs 4.2

How do roweditor in Ext.create("Ext.window.Window") by extjs 4.2.
Now, I can roweditor in grid,
but I want to roweditor when Ext.create("Ext.window.Window") .
If there is an error in my code, please tell me!!
this is my extjs code,please help me!!!!!
function sync1() {
var sm = grid.getSelectionModel();
var data1=[];
var rec = sm.getSelection();
$.each(rec,function(i,item) {
data1[i]=item.data.EQ_NO;
});
store1 = Ext.create("Ext.data.Store",
{
autoLoad : true, //自動載入
autoSync : false, //false為批量修改,預設是false,true代表一經修改會自動呼叫下面的api動作
proxy : { //store資料來源地處理方式
type : "ajax",
api : { //設定四種後端操作程式 (CRUD, 增讀改刪) 即可在編輯完畢後立即更新後端資料庫,保持前後端同步
read : "pocServlet?action=test&eq_no="+ data1,
creat : undefined,
update : "pocServlet?action=updateData",
destroy : "pocServlet?action=deleteData",
},
reader : {
type : "json",
totalProperty : "totalProperty",
//root : "root",
//idProperty : "id"
},
writer : {
type : "json",
encode : true, //讓servlet能看懂
writeAllFields : true,
allowSingle : false,
root : "data" //後端getParameter的參數名稱
},
listeners : {//Exception Handler for the Ajax Request
exception : function(proxy,response,operation) {
var error = Ext.decode(response.responseText);
Ext.MessageBox.show({
title : 'RULE DETAILS REMOTE EXCEPTION',
msg : error.message,
icon : Ext.MessageBox.ERROR,
buttons : Ext.Msg.OK
});
}
}
},
listeners : {
write : function(proxy,operation) {
console.log("writeResponseText="+ operation.response.responseText);
if (operation.response.responseText != 0) {
alert("Pass");
} else {
alert("Fail");
}
}
},
fields : [
{
name : "EQ_NO"
},
{
name : "REMARK"
},
{
name : "POSITION"
},
{
name : "MODIFY_USER"
},
{
name : "MODIFY_DATE"
},
]
});
columns1 = [{
header : "EQ.NO.",
dataIndex : "EQ_NO",
width : 200,
locked : true,
}, {
header : "Remark",
dataIndex : "REMARK",
width : 200,
editor : {}
}, {
header : "Position",
dataIndex : "POSITION",
width : 200,
editor : {}
}, {
header : "Modify_User",
dataIndex : "MODIFY_USER",
width : 200
}, {
header : "Modify_Date",
dataIndex : "MODIFY_DATE",
width : 200
} ]
win = Ext.create("Ext.window.Window", {
title: "Select Visit Vessel",
layout: 'fit',
maximizable: true,
width: 900,
height: 400,
tbar: {
xtype: 'toolbar',
frame: true,
border: false,
padding: 2
},
items: [{
xtype: 'grid',
store: store1,
columns: columns1,
}]
});
win.show();
};
I made an fiddle example for you, to show how rowediting works:
https://fiddle.sencha.com/#fiddle/g2t
Basically you have to set the appropriate form field in the editor property you want to use as editing option.

Extjs 4.1.1: Grid to Tree drag drop not working

I want to achieve something like this :
http://jsfiddle.net/mgill21/3HJXX/2/
But I whenever I drop a node from grid into the treecolumn (as a leaf node) I get errors such as node.updateInfo() is undefined and other node related undefined method.
Here is my code:
Ext.namespace('Ext.ux.window.ConfigureMobileApp');
Ext.require([ 'Ext.grid.*', 'Ext.data.*', 'Ext.dd.*' ]);
var firstGridStore = Ext.create('Ext.data.Store', {
storeId : 'formStore',
fields : [ 'name', 'type', 'itemId' ],
data : [ {
name : "Michael Scott",
itemId : 7,
type : "Management"
}, {
name : "Dwight Schrute",
itemId : 2,
type : "Sales"
}, {
name : "Jim Halpert",
itemId : 3,
type : "Sales"
}, {
name : "Kevin Malone",
itemId : 4,
type : "Accounting"
}, {
name : "Angela Martin",
itemId : 5,
type : "Accounting"
} ]
});
// declare the source Grid
var firstGrid = Ext.create('Ext.grid.Panel', {
viewConfig : {
plugins : {
ptype : 'gridviewdragdrop',
ddGroup : 'selDD'
}
},
store : Ext.data.StoreManager.lookup('formStore'),
columns : [ {
text : "Name",
flex : 1,
sortable : true,
dataIndex : 'name'
}, {
text : "Type",
width : 70,
sortable : true,
dataIndex : 'type'
} ],
stripeRows : true,
title : 'First Grid',
margins : '0 2 0 0',
width : 200
});
Ext.define('Resource', {
extend : 'Ext.data.Model',
fields : [ {
name : "name",
type : "string"
}, {
name : "type",
type : "string"
} ]
});
var store1 = Ext.create('Ext.data.TreeStore', {
storeId : 'treeStore',
fields : [ 'name', 'type', 'itemId' ],
root : {
expanded : true,
children : [ {
itemId : 171,
type : "comedy",
name : "Mr Bean",
children : [ {
leaf : true,
itemId : 171,
type : "actor",
name : "Rowan Atkinson"
} ],
}, {
itemId : 11,
type : "fantasy",
name : "Harry Potter",
children : [ {
itemId : 11,
leaf : true,
type : "actress",
name : "Emma Watson",
} ]
}, {
itemId : 173,
type : "Action",
name : "Fast and Furious",
children : [ {
itemId : 174,
type : "actor",
name : "Dwayne Johnson",
children : [ {
leaf : true,
itemId : 175,
type : "wrestler",
name : "The Rock"
} ]
} ]
} ]
}
});
Ext.define('Ext.ux.window.TreeGrid', {
extend : 'Ext.tree.Panel',
title : 'Demo',
height : 300,
rootVisible : true,
singleExpand : true,
store : Ext.data.StoreManager.lookup('treeStore'),
columns : [ {
xtype : 'treecolumn',
text : 'Name',
dataIndex : 'name',
width : 200
}, {
text : 'Type',
dataIndex : 'type'
} ],
initComponent : function() {
this.callParent();
},
viewConfig : {
plugins : {
ptype : 'treeviewdragdrop',
ddGroup : 'selDD'
},
listeners : {
beforedrop : function(node, data) {
debugger;
data.records[0].set('leaf', true);
data.records[0].set('expanded', false);
data.records[0].set('checked', true);
},
drop : function(node, data, dropRec, dropPosition) {
// firstGridStore.store.remove(data.records[0]);
}
}
}
});
var secondTree = Ext.create('Ext.ux.window.TreeGrid');
Ext.define('Ext.ux.window.ConfigureMobileApp', {
extend : 'Ext.window.Window',
title : 'Configure Mobile App',
height : 600,
width : 600,
layout : 'hbox',
modal : true,
closeAction : 'hide',
items : [ firstGrid, secondTree ]
});
Please help. Stuck since a very long time.
To help u out with this error i m sending u two links .These are not the proper solution but will surely guide u a way for that.
First Link
Second Link

Ext has many association store does not load

I have two models defined, ScoreCard and CaregoryWeight. A ScoreCard has many CategoryWeights.
When I create a grid and pass the association store to it (scoreCard.categoryWeights()), it displays nothing even though items are returned from the RESTful service.
What is wrong? please help.
Below is my code:
Ext.define(ModelNames.CategoryWeight, {
extend : 'Ext.data.Model',
idProperty : 'id',
fields : [ {
name : 'id',
type : 'int'
}, {
name : 'weight',
type : 'float'
}, {
name : 'category_id',
type : 'int'
}, {
name : 'scorecard_id',
type : 'int'
} ],
associations : [ {
type : 'belongsTo',
model : ModelNames.Category,
primaryKey : 'id',
forgientKey : 'category_id'
}, {
type : 'belongsTo',
model : ModelNames.ScoreCard,
primaryKey : 'id',
forgientKey : 'scorecard_id'
} ]});
Ext.define(ModelNames.ScoreCard, {
extend : 'Ext.data.Model',
idProperty : 'id',
fields : [ {
name : 'id',
type : 'int'
}, {
name : 'description',
type : 'string',
defaults : ''
}, {
name : 'isTemplate',
type : 'boolean',
defaults : true
}, {
name : 'isValid',
type : 'boolean',
defaults : false
} ],
associations : [ {
type : 'hasMany',
model : ModelNames.ScoreRecord,
name : 'scoreRecords',
storeConfig : {
autoLoad : true,
autoSync : true,
proxy : {
type : 'rest',
url : '/' + CONTEXT_PATH + '/RESTFul/ScoreRecord',
reader : {
type : 'json',
root : 'items'
},
writer : 'json'
}
}
}, {
type : 'hasMany',
model : ModelNames.CategoryWeight,
name : 'categoryWeights',
storeConfig : {
autoLoad : true,
autoSync : false,
proxy : {
type : 'rest',
url : '/' + CONTEXT_PATH + '/RESTFul/CategoryWeight',
reader : {
type : 'json',
root : 'items'
},
writer : 'json'
}
}
} ]});
Typo: foreignKey
Since answers are not allowed to be less than two words, I'll add that apart from spotting the typo, I have no idea if your code will work, why or why not.

Extjs 4 updateRecord error

(Sorry in advance if the post is to long, I just add all the code that is involved in the problem, then I think it could be easier to get an answer)
Hello, I'm encountering a problem when I try to update a store in extjs 4.
To back up a little I'm developing a general grid where you can send the columns you need and also a the fields in a window to add new rows to the grid, then this is the general grid:
Ext.define('masterDataGridControls', {
extend : 'Ext.grid.Panel',
id : 'panelWin',
windowItems : null,
addWin : null,
initComponent : function() {
var me = this;
Ext.applyIf(me, {
dockedItems : [{
xtype : 'toolbar',
dock : 'top',
items : [{
xtype : 'button',
id : 'btn_delete',
iconCls : 'deleteIcon',
tooltip : 'Delete row or group',
handler : function() {
var selection = me.getView()
.getSelectionModel()
.getSelection()[0];
if (selection) {
store.remove(selection);
}
}
}, {
xtype : 'button',
id : 'btn_add',
iconCls : 'addIcon',
tooltip : 'Add row or group',
handler : me.addToList
}]
}]
});
me.callParent(arguments);
},
getAddWindow : function() {
if (!this.addWin) {
this.addWin = new windowPop({
formItems : this.windowItems,
idParent : this.config.id,
record : this.store.model.prototype
});
}
return this.addWin;
},
addToList : function() {
var addWindow = this.findParentByType().findParentByType()
.getAddWindow();;
addWindow.show();
}
});
And I have the class windowPop that is the one who receives the fields, display them and save the data:
Ext.define("windowPop", {
extend : "Ext.window.Window",
formPanel : null,
formItems : null,
record : null,
idParent : null,
initComponent : function() {
var me = this;
me.formPanel = new Ext.form.Panel({
items : this.formItems,
layout: 'anchor'
});
Ext.applyIf(me, {
resizable : false,
closable : false,
width : 300,
minWidth : 300,
minHeight : 200,
y : 150,
layout : 'fit',
plain : true,
modal : true,
items : [me.formPanel],
buttons : [{
text : "i_Save",
handler : function() {
console.info(me.record);
me.formPanel.getForm().updateRecord(me.record);
Ext.getCmp(me.idParent).fireEvent("winSave",me.record);
me.formPanel.getForm().reset();
me.hide();
}
}, {
text : 'i_Cancel',
handler : function() {
me.formPanel.getForm().reset();
me.hide();
}
}]
});
me.callParent(arguments);
}
});
And I have my specific grid, where I define a data.model and for now I'm using a fixed store, but later on will be replace by the one I get from the server:
Ext.define('userKeys', {
extend : 'Ext.data.Model',
fields : [{
name : 'text',
type : 'string'
}, {
name : 'description',
type : 'string'
}, {
name : 'group',
type : 'string'
}]
});
var store = Ext.create('Ext.data.Store', {
model: 'userKeys',
data : [{
text : "que mamera",
description : "asdfasdf",
group : 'homework'
}, {
text : "book report",
description : 'hola',
group : 'homework'
}, {
text : "alegebra",
description : "haha",
group : 'homework'
}, {
text : "buy lottery tickets",
description : "kajsdf",
group : 'homework'
}]
});
Ext.define('ConfigInterfacesUserKeys', {
extend : 'masterDataGridControls',
initComponent : function() {
var me = this;
me.columns = [{
id : 'cl_input',
header : 'i_Text',
dataIndex : 'text',
width : 220
}, {
header : 'i_Description',
dataIndex : 'description',
width : 130
}, {
header : 'i_group',
dataIndex : 'group',
width : 130
}];
me.windowItems = [{
xtype : 'textfield',
id : 'txt_sendTime',
fieldLabel : 'text',
margin : '5 0 0 5',
style : 'font-weight:bold',
labelWidth : 120,
name : 'text'
}, {
xtype : 'textfield',
id : 'txt_waitTime',
fieldLabel : 'description',
margin : '5 0 0 5',
style : 'font-weight:bold',
labelWidth : 120,
name : 'description'
}, {
xtype : 'textfield',
id : 'txt_group',
fieldLabel : 'group',
margin : '5 0 0 5',
style : 'font-weight:bold',
labelWidth : 120,
name : 'group'
}];
me.store = store;
me.callParent(arguments);
}
})
The Problem
When I try to save the fields as you see in the windowPop class Im doing this:
me.formPanel.getForm().updateRecord(me.record);
But I get the next error:
this[this.persistenceProperty] is undefined
I tracked down the error and I find that all start when in the function updateRecord try to set the object to the store:
updateRecord: function(record) {
var fields = record.fields,
values = this.getFieldValues(),
name,
obj = {};
fields.each(function(f) {
name = f.name;
if (name in values) {
obj[name] = values[name];
}
});
record.beginEdit();
**record.set(obj);**
record.endEdit();
return this;
}
I don't know if it is something wrong when I send the model to the window from the general grid, I sent it this way:
record : this.store.model.prototype
Then I'm not sure if its because the model I'm sending its not well forme.
I've been searching the internet but I can't find a proper answer then it will be really helpful if you can guide me in the right way.
Thanks
I don't know if it is something wrong when I send the model to the
window from the general grid
I believe it is. You are sending not an empty instance (which should be sent) but a class' prototype. Try to send:
record : new this.store.model()

TreePanel Error : Uncaught TypeError: Cannot call method 'substring' of undefined

I've a problem while rendering TreePanel. I'm using MVC structure, here's my definition:
(By the way I don't use dynamic loading, included ext-all-debug.)
Menu - Model
Ext.define('RIA4.model.Menu', { extend : 'Ext.data.Model',
idProperty : 'menuId',
fields : [
{ name : 'menuId', type : 'int' },
{ name : 'menuName', type : 'string' },
{ name : 'sourcePath', type : 'string' },
{ name : 'active', type : 'boolean', defaultValue : true },
{ name : 'leaf', type : 'boolean' }
]
});
TreeStore
Ext.define('RIA4.store.Menus', { extend : 'Ext.data.TreeStore',
model : 'RIA4.model.Menu',
proxy : {
type : 'ajax',
api : {
read : 'menu/view.ajax'
},
reader : {
type : 'json',
root : 'data',
successProperty : 'success'
}
},
autoLoad : true
});
TreePanel
Ext.define('RIA4.view.menu.MenuTree', { extend : 'Ext.tree.Panel',
alias : 'widget.menutree',
//requires : [],
title : 'Menu List',
store : 'Menus',
rootVisible : false,
root : {expanded: true, text: "", "data": []}
});
I'll be happy if someone can help me?
Thanks in advance..
Haven't you forgotten to add the following line to controller's config:
views: [ 'menu.MenuTree' ],

Resources