PDA

View Full Version : ExtJs working examples for Rails



baran
7 Feb 2010, 10:33 AM
Hi All,
I am new to Ext and have some difficulties for starting. I downloaded TreeGrid example and tried to run it locally but no success.
Ext.onReady(function() {
Ext.QuickTips.init();
var tree = new Ext.ux.tree.TreeGrid({
title: 'my tasks',
width: 500,
height: 300,
renderTo: Ext.getBody(),
forceLayout : true,
enableDD: false,

columns:[{
header: 'Task',
dataIndex: 'task',
width: 230
},{
header: 'Duration',
width: 100,
dataIndex: 'duration',
align: 'center',
sortType: 'asFloat',
tpl: new Ext.XTemplate('{duration:this.formatHours}', {
formatHours: function(v) {
if(v < 1) {
return Math.round(v * 60) + ' mins';
} else if (Math.floor(v) !== v) {
var min = v - Math.floor(v);
return Math.floor(v) + 'h ' + Math.round(min * 60) + 'm';
} else {
return v + ' hour' + (v === 1 ? '' : 's');
}
}
})
},{
header: 'User',
width: 150,
dataIndex: 'user'
}],

//dataUrl: 'treegrid-data.json' that was originally. Even this does not work..
dataUrl: '/treegrid/getdata'


});Even the commented line does not work.

//dataUrl: 'treegrid-data.json' that was originally. Even this does not work..
dataUrl: '/treegrid/getdata'So this is the response but it does not bind any data!

{"Total":3,"Custs":[{"task":1,"duration":1.1,"user":"user1"},{"task":2,"duration":2.2,"user":"user2"},{"task":3,"duration":3.3,"user":"user3"}]}I will be really glad if somebody will point me to working examples with rails.
Thanks in advance.

Baran

evant
7 Feb 2010, 4:13 PM
If you aren't doing so, you need to run them through a web server.

baran
8 Feb 2010, 1:10 AM
Hi Evant,
I use a webserver. WEBRick 1.3.1. Here is web server starting Output in NetBeans.

[2010-02-08 09:40:53] INFO WEBrick 1.3.1
[2010-02-08 09:40:53] INFO ruby 1.8.7 (2008-08-11) [i386-mswin32]
[2010-02-08 09:40:53] INFO WEBrick::HTTPServer#start: pid=2916 port=3030Baran

sramazzina
8 Feb 2010, 2:17 AM
I normally wrote ExtJS code in Rails but I wasn't ever able to intermix ruby code with javascript code in .html.erb pages. So I'm used to generate the needed javascript inside appropriates helper methods.

I hope this helps...

S.

baran
8 Feb 2010, 4:11 AM
Hi Sramazzina,
Thanks for your response.
I normally wrote ExtJS code in Rails but I wasn't ever able to intermix ruby code with javascript code in .html.erb pages. So I'm used to generate the needed javascript inside appropriates helper methods.Do you mean in myApp/helpers/myhelper.rb
Could you give a simple Example please?

Thanks
Baran

kumakinsey
27 Sep 2013, 10:23 PM
Hello,

I have made an example app to demonstrate integration between Rails and ExtJS (used Rails4 and Extjs 4.1.0), deployed @ heroku. For the authentication, I used Devise. For authorization, the_role ?gem is used.

The app is located at teamsheet.herokuapp.com

The source code + install instruction: https://github.com/weyewe/timesheet

The app design: http://weyewe.com/rails-extjs-timesheet-tracker