Grid data not being displayed in ExtJs app [closed] - extjs

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I'm using ExtJs 4.1.0 and I'm trying to display a grid of data backed by a remote json store. When I render the grid like so:
Ext.Loader.setConfig({enabled:true});
Ext.Loader.setPath({
'Grip':'app'
,'Ext.ux':'ext/examples/ux'
});
Ext.require([
'Grip.view.EditableGrid'
,'Grip.store.UYNMeetingTypes'
,'Grip.view.UYNMeetingGrid'
,'Grip.model.UYNMeeting'
,'Grip.store.UYNMeetings'
,'Ext.ux.CheckColumn'
]);
Ext.require([
'Ext.panel.*',
'Ext.toolbar.*',
'Ext.button.*',
'Ext.container.ButtonGroup',
'Ext.layout.container.Table',
'Ext.tip.QuickTipManager'
]);
Ext.onReady(function() {
var store = new Grip.store.UYNMeetings();
grid = new Grip.view.UYNMeetingGrid({
store: store
,renderTo: Ext.getBody()
});
store.load({
// store loading is asynchronous, use a load listener or callback to handle results
callback: function(){
Ext.Msg.show({
title: 'Store Load Callback',
msg: 'store was loaded, data available for processing',
modal: false,
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
});
}
});
});
it works fine. However, when I try to link things up using the manner suggested in the MVC tutorial (http://www.sencha.com/learn/architecting-your-app-in-ext-js-4-part-2/) I can't seem to get my data to display. I'm running ExtJs 4.1.0 on Google Chrome 20.0.1132.47. Any ideas?
I tried to post only the minimally relevant bits of code (though it still seems like a lot). Let me know if there's anything I can clarify. Any help would be greatly appreciated. Thanks!
Grip.controller.UYNMeeting:
Ext.define('Grip.controller.UYNMeeting', {
extend: 'Ext.app.Controller',
refs: [{
ref: 'meetingGrid',
selector: 'uynmeetinggrid'
}],
stores: ['UYNMeetings','UYNMeetingTypes'],
init: function() {
},
onLaunch: function() {
var meetingsStore = this.getUYNMeetingsStore();
meetingsStore.load({
callback: this.onMeetingsLoad,
scope: this
});
var meetingTypesStore = this.getUYNMeetingTypesStore();
meetingTypesStore.load({
callback: this.onMeetingTypesLoad,
scope: this
});
},
onMeetingsLoad: function() {
},
onMeetingTypesLoad: function() {
Ext.Msg.show({
title: 'Store Load Callback',
msg: 'store was loaded, data available for processing',
modal: false,
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
});
}
});
Grip.view.UYNMeetingGrid:
var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToMoveEditor: 1,
autoCancel: false
});
Ext.define('Grip.view.UYNComboBox', {
extend:'Ext.form.field.ComboBox'
,alias:'widget.uyncombo'
,stores:['UYNMeetingTypes']
})
Ext.define('Grip.view.UYNMeetingGrid', {
extend:'Ext.grid.Panel'
,alias:'widget.uynmeetinggrid'
,stores:['UYNMeetings']
,title:'UYN Meetings Grid'
,hideHeaders: true
,bodyPadding:5
,width:550
,height:400
,autoScroll: true
,initComponent:function(){
this.columns = [{
"width": 150,
"text": "Name",
"sortable": true,
//"id": "name",
"dataIndex": "name",
editor: {
allowBlank: false,
xtype: 'textfield'
}
},
{
"width": 150,
"text": "Org.",
"sortable": true,
//"id": "org",
"dataIndex": "org",
editor: {
allowBlank: true,
xtype: 'textfield'
}
},
{
"width": 100,
"text": "Date",
"sortable": true,
//"id": "date",
"dataIndex": "date",
editor: {
xtype: 'datefield',
allowBlank: false,
format: 'm/d/Y',
maxText: 'Cannot have a meeting date in the future!',
maxValue: Ext.Date.format(new Date(), 'm/d/Y')
}
},
{
"width": 75,
"text": "Meeting Type",
"sortable": true,
//"id": "meeting_type",
"dataIndex": "meeting_type"/*,
editor: {
xtype: 'uyncombo'
}*/
},
{
"width": 75,
"text": "Num Hours",
"sortable": true,
//"id": "num_hours",
"dataIndex": "num_hours",
editor: {
allowBlank: false,
// step: '.1',
xtype: 'numberfield'
}
}];
this.dockedItems = [{
dock:'bottom'
,xtype:'toolbar'
,items: [{
xtype:'button'
,text:'New'
,action:'newuynmeeting'
}, {
xtype:'button'
,text:'Edit'
,action:'edituynmeeting'
}, {
xtype:'button'
,text:'Remove'
,action:'removeuynmeeting'
}]
}];
this.callParent();
}
,plugins: [rowEditing]
,listeners: {
'selectionchange': function(view, records) {
// grid.down('#removeEmployee').setDisabled(!records.length);
}
}
});
Grip.view.Viewport:
Ext.define('Grip.view.Viewport', {
extend: 'Ext.container.Viewport',
layout: 'fit',
requires: [
'Grip.view.ContactsPanel'
,'Grip.view.UYNMeetingForm'
,'Grip.view.UYNMeetingGrid'
,'Grip.view.NavBar'
],
renderTo: 'app',
tbar:{
xtype:'mynavbar'
},
items:[{
xtype:'tabpanel',
items:[{
title:'Contacts',
xtype:'tabpanel',
items:[{
title:'Contacts'
,xtype:'contactspanel'
},{
title:'Add Contact'
,html:'TODO: Add content'
}
]
},{
title:'UYN',
xtype:'tabpanel',
items:[{
title:'UYN Meetings'
//,html:'Foo'
,xtype:'uynmeetinggrid'
}]
}]
}]
});

I don't know if it's a typo, but a grid doesn't have a stores config - it can only display the data of one store, thus it has a store config (singular, not plural)

Related

extjs 6 grid scrollbar jumping

I have an extjs 6.0.1.250 grid, with a remote json store, it is loading every 2 seconds, to refresh its data. It shows a device list with the device statuses, about 200 lines. (name, uptime, etc...)
When a user scrolls the scrollbar with the mouse the grid does not keep its position but jumps with to the old place. Is there a solution to use it normally with scrolling?
Using a taskManager:
this.config.pmConfig.deviceRefreshTask =
{
run: function()
{
var store=this.getDevicesGetDevicesStore();
store.proxy.setExtraParam('eventDisableLoader', true);
store.load();
},
interval: 2000, // 2 second, this will update the progressbar
scope: this
};
Ext.TaskManager.start(this.config.pmConfig.deviceRefreshTask); // start the first timer
And here is the grid:
xtype: 'gridpanel',
viewConfig: {
loadMask: false
},
itemId: 'devicesGrid',
width: 40,
title: '``Devices``',
emptyText: '``There is no device in this group.``',
store: 'Devices.GetDevices',
columns: [
{
xtype: 'gridcolumn',
hidden: true,
width: 80,
align: 'right',
dataIndex: 'id',
text: 'Id'
},
//....... more normal and some action columns.....
],
viewConfig: {
itemId: 'devicesGridTableView',
loadMask: false,
preserveScrollOnRefresh: true,
preserveScrollOnReload: true,
plugins: [
{
ptype: 'gridviewdragdrop',
ddGroup: 'deviceGroups',
enableDrop: false
}
]
},
tabConfig: {
xtype: 'tab',
dock: 'left'
},
features: [
{
ftype: 'grouping',
groupHeaderTpl: [
'<b>{name}</b>'
]
}
],
selModel: {
selType: 'checkboxmodel'
}
Arthurs suggestion is helped: "In the grid definition you can try to use bufferedRenderer: false"
thanks.

EXTJS creating custom tree panel

I am using EXTJS and I want to create my TreePanel with one more icon to the right that will be set to indicate something has changed. I am struggling to do this as I am unsure where I can modify these properties. It would be easy with HTML alone but obviously this framework is useful and I need to integrate these changes into it.
Thanks,
Dan
Yes, there is way to handle it in ExtJS framework with renderer method on column.
Here is how I would achieve it using ExtJS 6.0.x:
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [{
xtype: 'container',
scrollable: 'y',
flex: 1,
layout: {
type: 'hbox',
alignt: 'stretchmax'
},
items: [{
xtype: 'treepanel',
rootVisible: false,
flex: 1,
store: {
type: 'tree',
parentIdProperty: 'parentId',
root: {
text: 'Navigation Bar',
expanded: true,
children: [{
text: 'Parts',
children: [{
leaf: true,
itemId: 'addPart',
text: 'Add new part',
changed: true
}, {
leaf: true,
itemId: 'manageParts',
text: 'Manage Parts',
changed: false
}, ]
}, {
leaf: true,
itemId: 'announcements',
text: 'Announcements',
changed: true
}]
}
},
columns: [{
text: 'Code',
dataIndex: 'codigo',
align: 'left'
}, {
xtype: 'treecolumn',
text: 'Description',
dataIndex: 'text',
flex: 1
}, {
text: 'Edited',
iconCls: 'x-fa fa-edit',
align: 'center',
flex: 1,
renderer: function (f, grid, record) {
if(record.get('changed') === true) {
return "Changed Icon here"
}
else {
return "Not changed icon here";
}
}
}]
}]
}]
});
With this you can easily manage the data with store and can easily update the data in store. ExtJS will take care of rendering the given configuration for columns.
You can also use actioncolumn to show icons/buttons and handle events with listeners.
Example Fiddle: https://fiddle.sencha.com/#view/editor&fiddle/28qm
I Have solved the problem. You can embed html into the text field in the store.
Ext.define('MyApp.store.Navigation', {
extend: 'Ext.data.TreeStore',
alias: 'store.navigation',
rootData: {
text: 'Navigation Bar',
expanded: true,
children: [
{
text: 'Parts',
children: [
{ leaf:true, itemId:'addPart', text: 'Add new part' },
{ leaf:true, itemId:'manageParts', text: 'Manage Parts <b>here</b>' },
]
},
{
leaf:true, itemId:'announcements', text: 'Announcements'
}
]
},
constructor: function (config) {
// Since records claim the data object given to them, clone the data
// for each instance.
config = Ext.apply({
root: Ext.clone(this.rootData)
}, config);
this.callParent([config]);
}
});
Probably a poor solution but gets the job done.

How to make a User story ID act as a link in the custom report in rally

I have created a report which displays user story ID, name of the story, current kanban state of the story and total number of days the story stayed in each state as shown below using extjs. But i want the ID to act as a link in the report that is when clicked, it should display the information of story just like how when user story is clicked in the kanban board,it displays that story information.
var gridbox = Ext.create('Ext.grid.Panel', {
store: data,
columnLines: true,
columns: [
{
text: 'Formatted ID',
dataIndex: 'FormattedID',
},
{
text: 'Name',
dataIndex: 'Name',
},
{
text: 'Current Kanban State',
dataIndex: 'c_Kanban',
},
{
text: 'Ready',
dataIndex: 'ready',
},
{
text: 'In Development',
dataIndex: 'indev',
componentCls:'columnstyle',
},
{
text: 'Development Done',
dataIndex: 'devdone',
}
],
viewConfig: {
stripeRows: true
}
});
this.add(gridbox);`
Is there a reason you're not using the Rally.ui.Grid component in the AppSDK? That should wire up the correct FormattedID renderer for you, in addition to having consistent styling with the rest of the product:
this.add({
xtype: 'rallygrid',
columnCfgs: [
'FormattedID',
'Name',
{
text: 'Current Kanban State',
dataIndex: 'c_Kanban'
},
'Ready',
{
text: 'In Development',
dataIndex: 'indev',
componentCls:'columnstyle',
},
{
text: 'Development Done',
dataIndex: 'devdone',
}
],
enableEditing: false,
showRowActionsColumn: false,
store: data,
columnLines: true,
viewConfig: {
stripeRows: true
}
});

Custom drag'n'drop from a tree to a grid with Extjs5

The Ext.grid.plugin.DragDropView and Ext.tree.plugin.TreeViewDragDropView are great to allow drag'n'drop functionnality over those components but I don't want the store modification thing when I drag and drop an item.
I want custom functions, like, when I drop an item on my grid, I don't want the drag component source store to be modified and I don't want the drop component store to be modified too. I would like a function of mine to be called instead.
How to do this?
Do I need to use DragZone and DropZone instead?
You are on the right path, and looking in the right areas. The plugins that you have mentioned are exactly what you need for this purpose and provide the DragZone and DropZone functionality within.
I have written a simple example of using these plugins together, Fiddle Here.
The thing to watch out for here... If you do not want the default functionality of moving a record between stores you will likely need to run your own logic in the beforeDrop event and call the cancelDrop method, to prevent default behaviour, this is demonstrated in the fiddle and code below.
Make sure that both plugins share the same ddGroup.
Ext.application({
name: 'Fiddle',
launch: function() {
// create a very simple tree view
var treeStore = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [{
text: "detention",
leaf: true
}, {
text: "homework",
expanded: true,
children: [{
text: "book report",
leaf: true
}, {
text: "algebra",
leaf: true
}]
}, {
text: "buy lottery tickets",
leaf: true
}]
}
});
var gridStore = Ext.create('Ext.data.Store', {
storeId: 'simpsonsStore',
fields: ['name', 'email', 'phone'],
data: {
'items': [{
'name': 'Lisa',
"email": "lisa#simpsons.com",
"phone": "555-111-1224"
}, {
'name': 'Bart',
"email": "bart#simpsons.com",
"phone": "555-222-1234"
}, {
'name': 'Homer',
"email": "homer#simpsons.com",
"phone": "555-222-1244"
}, {
'name': 'Marge',
"email": "marge#simpsons.com",
"phone": "555-222-1254"
}]
},
proxy: {
type: 'memory',
reader: {
type: 'json',
rootProperty: 'items'
}
}
});
Ext.create('Ext.panel.Panel', {
renderTo: Ext.getBody(),
layout: 'fit',
height: 800,
width: 800,
items: [{
layout: 'border',
title: "DnD",
height: '100%',
items: [{
xtype: 'grid',
region: 'center',
store: gridStore,
columns: [{
text: 'Name',
dataIndex: 'name'
}, {
text: 'Email',
dataIndex: 'email',
flex: 1
}, {
text: 'Phone',
dataIndex: 'phone'
}],
viewConfig: {
plugins: {
ptype: 'gridviewdragdrop',
enableDrag: false,
enableDrop: true,
ddGroup: 'myDropGroup'
},
listeners: {
beforedrop: function(node, data, overModel, dropPosition, dropHandlers) {
// Defer the handling
dropHandlers.wait = true;
// here you have the record from the treeview and can do anything you like with it.
var record = data.records[0];
Ext.MessageBox.confirm('Drop', 'Your are about to drop ' + record.get('text') + ', Are you sure?', function(btn) {
if (btn === 'yes') {
dropHandlers.processDrop();
} else {
// IMPORTANT - In this case, we want to cancel the drop as the records aren't compatible
dropHandlers.cancelDrop();
}
});
}
}
}
}, {
xtype: 'treepanel',
width: '40%',
region: 'west',
store: treeStore,
rootVisible: false,
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop',
enableDrop: false,
ddGroup: 'myDropGroup'
}
}
}]
}]
});
}
});

extjs: Grid Buffered Scrolling with Row Editing/Deletion/Addition

Has anybody seen any sample of extjs grid with buffered scrolling with new row, row editing and row deletion support?
Can CellEditing and RowEditing plugins be used with Buffered Scrolling?
Is row editing even possible with buffered scrolling?
Cheers,
Avi
I had opened a thread at Ext forum and got the response, insertion and deletion is NOT supported with buffered scrolling.
http://forums.ext.net/showthread.php?27969-Buffered-Scrolling-with-Row-Editing-Deletion-Addition&p=124559&posted=1#post124559
Cheers,
Avi
I changed this example http://docs.sencha.com/extjs/4.2.2/#!/example/grid/infinite-scroll.html, added the row editor. Open this example: http://jsfiddle.net/zAnZg/1/, click on record, change values and then click "Update"
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.util.*',
'Ext.grid.plugin.BufferedRenderer'
]);
Ext.onReady(function(){
Ext.define('ForumThread', {
extend: 'Ext.data.Model',
fields: [
'title', 'forumtitle', 'forumid', 'username', {
name: 'replycount',
type: 'int'
}, {
name: 'lastpost',
mapping: 'lastpost',
type: 'date',
dateFormat: 'timestamp'
},
'lastposter', 'excerpt', 'threadid'
],
idProperty: 'threadid'
});
// create the Data Store
var store = Ext.create('Ext.data.Store', {
id: 'store',
model: 'ForumThread',
remoteGroup: true,
// allow the grid to interact with the paging scroller by buffering
buffered: true,
leadingBufferZone: 300,
pageSize: 100,
proxy: {
// load using script tags for cross domain, if the data in on the same domain as
// this page, an Ajax proxy would be better
type: 'jsonp',
url: 'http://www.sencha.com/forum/remote_topics/index.php',
reader: {
root: 'topics',
totalProperty: 'totalCount'
},
// sends single sort as multi parameter
simpleSortMode: true,
// sends single group as multi parameter
simpleGroupMode: true,
// This particular service cannot sort on more than one field, so grouping === sorting.
groupParam: 'sort',
groupDirectionParam: 'dir'
},
sorters: [{
property: 'threadid',
direction: 'ASC'
}],
autoLoad: true,
listeners: {
// This particular service cannot sort on more than one field, so if grouped, disable sorting
groupchange: function(store, groupers) {
var sortable = !store.isGrouped(),
headers = grid.headerCt.getVisibleGridColumns(),
i, len = headers.length;
for (i = 0; i < len; i++) {
headers[i].sortable = (headers[i].sortable !== undefined) ? headers[i].sortable : sortable;
}
},
// This particular service cannot sort on more than one field, so if grouped, disable sorting
beforeprefetch: function(store, operation) {
if (operation.groupers && operation.groupers.length) {
delete operation.sorters;
}
}
}
});
function renderTopic(value, p, record) {
return Ext.String.format(
'{0}',
value,
record.data.forumtitle,
record.getId(),
record.data.forumid
);
}
var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToMoveEditor: 1,
clicksToEdit: 1,
autoCancel: false,
listeners:{
edit: function(editor, e){
Ext.MessageBox.alert(
'Just create Ajax recuest here. Post changed record:<br/>' +
Ext.JSON.encode(e.record.data)
);
}
}
});
var grid = Ext.create('Ext.grid.Panel', {
width: 700,
height: 500,
collapsible: true,
title: 'ExtJS.com - Browse Forums',
store: store,
loadMask: true,
selModel: {
pruneRemoved: false
},
multiSelect: true,
viewConfig: {
trackOver: false
},
features:[{
ftype: 'grouping',
hideGroupedHeader: false
}],
plugins: [rowEditing],
// grid columns
columns:[{
xtype: 'rownumberer',
width: 50,
sortable: false
},{
tdCls: 'x-grid-cell-topic',
text: "Topic",
dataIndex: 'title',
flex: 1,
renderer: renderTopic,
sortable: true,
editor: {
allowBlank: false
}
},{
text: "Author",
dataIndex: 'username',
width: 100,
hidden: true,
sortable: true
},{
text: "Replies",
dataIndex: 'replycount',
align: 'center',
width: 70,
sortable: false,
editor: {
xtype: 'numberfield',
allowBlank: false,
minValue: 1,
maxValue: 150000
}
},{
id: 'last',
text: "Last Post",
dataIndex: 'lastpost',
width: 130,
renderer: Ext.util.Format.dateRenderer('n/j/Y g:i A'),
sortable: true,
groupable: false,
editor: {
xtype: 'datefield',
allowBlank: false,
format: 'm/d/Y',
minValue: '01/01/2006',
minText: 'Cannot have a start date before the company existed!',
maxValue: Ext.Date.format(new Date(), 'm/d/Y')
}
}],
renderTo: Ext.getBody()
});
});

Resources