PDA

View Full Version : Bancha - Combining CakePHP and ExtJS



Dumas
28 Jul 2011, 4:04 AM
http://docs.banchaproject.org/wiki/images/github-logo.png (http://banchaproject.com)



Bancha integrates ExtJS 4 and Sencha Touch with the light-weight PHP-MVC-­Framework CakePHP 2 (http://cakephp.org/).

Basically it:


handles all communication between server and client
shares all Schema and validation rules in CakePHP with ExtJS/Sencha Touch
enables asynchronous and batched request to the server
automatically implements CRUD for all remotable cake models
is well-tested with PHPUnit and Jasmine


http://vimeo.com/38992059

For ExtJS & Touch Developers

Bancha provides a simple interface to create models. These models get all fields, validations and associations and a fully configured proxy from the server.

Just use Bancha.onModelReady('User', callback); and Bancha does the rest.


We would appreciate any comments and ideas.

For more Information:
- follow us on twitter @banchaproject
(http://twitter.com/#!/banchaproject) - see the examples (http://samples.banchaproject.org/)
- read our dokumentation
(https://github.com/Bancha/Bancha/wiki) - read the JS API Docs
(http://docs.banchaproject.org/js/index.html#/api/Bancha) - get the code
(http://banchaproject.org/download.html)

edspencer
29 Jul 2011, 4:06 PM
This sounds awesome - got screencast?

FlaminPhoenix
1 Aug 2011, 12:28 AM
Awesome idea.. we use cakephp and ExtJS too.. would love to see you guys make it mainstream with this.

Dumas
15 Aug 2011, 7:31 AM
@edspencer:
No, there's not much you have to know as normal dev, On the Cake-side you just add the project as plugin, the ExtJS-Side you just add the library. Some samples will follow soon with the first release!
API Docs can be found here: http://docs.banchaproject.org/js/#/api/Bancha

@FlaminPhoenix:
Cool, hope you guys will like it :)

regards
Roland

mikolajj
30 Aug 2011, 12:25 PM
Clean installation, cakephp + bancha.
I took controller sample from http://samples.banchaproject.org/UsersController.php.txt
and copy this file to app/Controller folder.

But I can't work out where to put this js file from exapmle http://samples.banchaproject.org/js/samples.js ?

As I read about how "it" (bancha) works It should be a part of code generated by bancha as View.
This code is then interpreted by browser and ExtJS is starting (is rendered) inside of web browser.

Am I correct?
Where to put this example js file ?
How to create proper View?

So in a few words ;-) need this example with more complex comment ;-)

Regards
MJ

Dumas
4 Sep 2011, 10:40 AM
Hi!

The project is in development, not yet released! The samples aren't working yet!

We had a few issues with mapping in our dispatcher, we're planning to release somewhere in the next two weeks.

On the ExtJS side you just need to use the Bancha API to get models and model data.
Inside CakePHP you just have to create the (almost) standard cake crud methods, description on that will follow soon.

Best regards,
Roland

mikolajj
4 Sep 2011, 11:10 AM
Looking forward to see it in action ;-)

Is there any official group or RSS about Bancha, where I can fallow progress of your work?

Beat Regards
MJ

Dumas
4 Sep 2011, 4:47 PM
You can follow us on @banchaproject (http://twitter.com/banchaproject).
We will also announce the first release here in the forums.

have a nice day
Roland

justinledwards
27 Oct 2011, 5:15 AM
How are things coming along?

Dumas
31 Oct 2011, 7:46 PM
Yeah, last weeks were very busy. I moved to another country and we all had much to do for work/university. But now we are on it again.

We found the error and currently fixing it. We are also overviewing the whole technical documentation again.

I really plan to finish it soon.

cheers
Roland

djcode
10 Nov 2011, 1:00 PM
This is awesome. I would love to help out in any way that I can, I'll be following you on twitter and start poking around in GitHub :)

Dumas
21 Nov 2011, 7:43 AM
The work on Bancha is going very well, first release will be out on 30th of november (party)
http://banchaproject.org/

Dumas
30 Nov 2011, 1:05 PM
Over the last two weeks we have produced over 90 commits finally resulting in the first beta release. Have fun. http://banchaproject.org

justinledwards
30 Nov 2011, 5:19 PM
I like what I see! You guys are doing a really good job.

djcode
2 Dec 2011, 9:30 AM
Just got bancha setup in my app with the sample code. I have to say, you guys have done an amazing job so far. The code is clean, easy to follow, and I love all the auto-magic integration with Cake.

Amazing job guys and I hope to help as much as I can!

djcode
14 Dec 2011, 12:17 PM
Hey Guys,

I was wondering what the best way to add additional methods to controllers so that they may be called via Ext Direct. Basically anything that is not a standard crud method.

How have you guys handled this in your apps? I assume there are instances when you have additional controller methods that you want to call from your Ext app.

Thanks!

Dumas
14 Dec 2011, 12:49 PM
Hi!

Yes, you are true. That's important.

Sadly we didn't found the time to implement it yet. It's already on our roadmap (https://github.com/Bancha/Bancha/wiki/Roadmap) (1.2 Release)

cheers
Roland

djcode
14 Dec 2011, 12:54 PM
Ahh I see.

Thanks for the reply Roland! B)

vinh2012
15 Dec 2011, 10:19 PM
Yeah, last weeks were very busy. I moved to another country and we all had much to do for work/university. But now we are on it again.

We found the error and currently fixing it. We are also overviewing the whole technical documentation again.

I really plan to finish it soon.

cheers
Roland

thank's you !

Dumas
16 Dec 2011, 3:47 AM
Hi!

Why are you quoting an old post? First release of Bancha already exists!
http://banchaproject.org

regards
Roland

Sheraton
20 Dec 2011, 12:35 AM
ok thank's you !

tjscooper
13 Jan 2012, 2:34 PM
Just checking in... I'm really looking forward to some kind of screencast!

Always best to see/hear it explained in the author's words ;)

Dumas
14 Jan 2012, 6:53 PM
Hey!

I just updated and extened the documentation. The next two things will be a small 5min screencast and the ability to expose controller methods ;-)

cheers
Roland

Dumas
29 Jan 2012, 10:21 AM
The new release is out!

Bancha now provides the possibility to expose all controller methods, and has some mayor refactoring in the new build.

Screencast is comming soon.

Enjoy!
Roland

klander
29 Jan 2012, 6:05 PM
Great Stuff with the new release.. though me being a noob, ive run into a few issues..

I have a Model 'User', but Bancha seems to be trying to get UserController->view instead of UsersController->view
Uncaught Ext.Error: Bancha: Tried to call User.read(...), but the server-side has not implemented UserController->view or index(...) ext-all-dev.js:8712 (http://localhost/bancha/js/ext-all-dev.js)
changing it from Bancha.onModelReady('User') to Bancha.onModelReady('Users') seems to make it go away.

also, my app is hosted in a sub-dir, and not the webroot. ive changed all the paths accordingly but i get the following error:

POST http://localhost/bancha.php 404 (Not Found) Ext.define.request[/COLOR]ext-all-dev.js:27958 (http://localhost/bancha/js/ext-all-dev.js)
It needs to pull in http://localhost/bancha/bancha.php instead. I cant seem to find where I can set this?

Thanks much!


(http://localhost/bancha/js/ext-all-dev.js)

klander
29 Jan 2012, 7:26 PM
OK So i reverted to Bancha.onModelReady('User'), and created an http redirect from http://localhost/bancha.php to http://localhost/bancha/bancha.php, but Now i get the following error:


el is null

--> if (el.insertAdjacentHTML) { ext-all-dev.js (line 11856)



"You're trying to decode an invalid JSON String":
sourceClass "Ext.JSON"
sourceMethod "decode"

Dumas
30 Jan 2012, 9:27 AM
Hi!




I have a Model 'User', but Bancha seems to be trying to get UserController->view instead of UsersController->view
We are using the standard ext and cake conventions. So the cake model name is singular, the controller name plural with "Controller" suffix.
In our example implementation we also have a user model, the model name is "User", the controller "UsersController", the ExtJS model name "User".
The error must be somewhere else.




Uncaught Ext.Error: Bancha: Tried to call User.read(...), but the server-side has not implemented UserController->view or index(...) ext-all-dev.js:8712 (http://localhost/bancha/js/ext-all-dev.js)

Ok, so here the error message is wrong, it should be in plural.. but the dispatcher is definitely looking for UsersController!



changing it from Bancha.onModelReady('User') to Bancha.onModelReady('Users') seems to make it go away.

Is your cake model really singular!? It should look something like this:
https://github.com/Bancha/BanchaTestProject/blob/master/Model/User.php
Please always use Bancha.onModelReady('User',callback);




also, my app is hosted in a sub-dir, and not the webroot. ive changed all the paths accordingly but i get the following error

POST http://localhost/bancha.php 404 (Not Found) Ext.define.request[/COLOR]ext-all-dev.js:27958 (http://localhost/bancha/js/ext-all-dev.js)

This was actually an error, please try this controller and tell me if it is working now:
https://github.com/rolandschuetz/Bancha/blob/master/Controller/BanchaController.php



OK So i reverted to Bancha.onModelReady('User'), and created an http redirect from http://localhost/bancha.php to http://localhost/bancha/bancha.php, but Now i get the following error:

el is null

--> if (el.insertAdjacentHTML) { ext-all-dev.js (line 11856)


"You're trying to decode an invalid JSON String":
sourceClass "Ext.JSON"
sourceMethod "decode"
Is it somewhere online so I can test it? Otherwise, can you please post the value of /bancha/bancha-api.js and of the last xhr, which created the error.

best regards
Roland

klander
30 Jan 2012, 1:00 PM
Hi Ronald,

Thanks for the pointers!

So using the revised BanchaController.php, It gives me an "You're trying to decode an invalid JSON String:" when loading the page. So it does not load the grid panel. However, it appears to be receiving the JSON data as you can see here in my browser error log: http://pastebin.com/gRgMm59p

I (http://pastebin.com/gRgMm59p) dont seem to have a /bancha/bancha-api.js anywhere in my app. Could this be the problem?

Here are the contents of my Bancha.js: http://pastebin.com/QmsHdmbt
(http://pastebin.com/QmsHdmbt)sample.js: http://pastebin.com/cWnEnfSy
(http://pastebin.com/cWnEnfSy)

Best,
Klander

Dumas
30 Jan 2012, 5:00 PM
Hi!

Now I'm seeing where the problem is. My colleague forgot to push his last changes.... sry
Please just place this new file inside your webroot:
https://github.com/Bancha/Bancha/blob/master/_app/webroot/bancha.php

bancha-api.js is created from our plugin, so you can only see it inside your browser, not in the file system ;-)

best regards
Roland

klander
30 Jan 2012, 7:33 PM
Hey!

So it works now :)

A minor thing is it tries to pull http://localhost/img/icons/delete.png even though ive set it to icon: '/bancha/img/icons/delete.png' in bancha/app/webroot/js/Bancha.js. I was not able to find this setting in any other file so i got around it temporarily by coping the /img/ directory to my DocumentRoot.

Otherwise all CRUD functions work perfectly now :)

Thanks again for your help! I'm really looking forward to seeing this project mature. Big fan! :)

Cheers!

Klander

Dumas
30 Jan 2012, 8:12 PM
Hi!

This is probably just your cache ;-)
The delete icon is only mentioned one time in Bancha.js.

Please NEVER change a library file, that's bad. Use this instead:

Bancha.scaffold.Grid.destroyButtonConfig.items[0].icon = '/absolute-path/delete.png';

Best regards
Roland

wirtsi
31 Jan 2012, 1:32 AM
Hi

i know you guys only just started this, but this a feature that is probably needed sooner or later ;)

How can I display associated data in the grid or the form?

Something like this

Article -> belongsTo -> Collection
Collection -> hasMany -> Article

When viewing the Article grid, all I can see is the collection_id field and the collection's index ... but I would like to see Collection.name.

The same unfortunately goes for HABTM ... this should be even a bit trickier

All the best & thanks for your hard word

wirtsi

Dumas
31 Jan 2012, 1:45 PM
Hi!

Bancha is actually three things:
- On the lowest layer it implements Ext.Direct in CakePHP
- On top of this it provides cake models in extjs
- and on top of this scaffold models (this part is missing for associations)

So Bancha already provides all the possibilities to load the associated data (ext models are correctly associated). Only the scaffolding is missing yet.

Well, we have more then just started, we already spend a few hundred hours on it. Of course, there is still much possibilities to extend ;)

So for your usage just add normal ExtJS column-code to the afterBuild interceptor:

Ext.create('Ext.grid.Panel', {
scaffold: {
afterBuild: function(config) {
config.columns.push({...});
return config;
},
....
}
});
For more see js api docs (http://docs.banchaproject.org/js/index.html#/api/Bancha.scaffold.Grid-method-afterBuild)

best regards
Roland

systematical
2 Feb 2012, 4:20 PM
So bancha seems to be working well. I have gone through the examples and the scaffolding works like a charm. Bancha has consumed my cakephp model in an extjs model nicely. I am trying to step out of simply using scaffoliding though by building my own data store into a grid with row editing. I am having problems saving the data using the extjs model bancha has created and was wondering if you could provide some pointers. As a disclaimer I only just started using extjs this monday so please be nice to a noob.

I can get the following to work, but I know its not the right way. You can see from what was commented out what I was trying to do (thinking thats closer to the right way).



Bancha.onModelReady('Campaign', function() {


Bancha.RemoteStubs.Campaign.index(function(result) {


var myStore = Ext.create('Ext.data.JsonStore', {
model: Bancha.getModel('Campaign'),
data: result.data
});


var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToMoveEditor: 1,
autoCancel: false
});


Ext.create('Ext.grid.Panel', {
title:'Campaigns',
renderTo: 'LeftPanel-body',
store: myStore,
plugins: [rowEditing],
frame: true,
columns: [
{header: "Campaign", flex: 1, dataIndex: 'name', sortable: true, editor:{allowBlank: false}},
{text: "Created", flex: 1, dataIndex: 'created', sortable: true},
{
xtype:'actioncolumn',
width:20,
items: [{
icon: '/js/app/extjs/examples/shared/icons/fam/cog_edit.png', // Use a URL in the icon config
tooltip: 'Edit',
handler: function(grid, rowIndex, colIndex) {
loadPageGrid(grid.getStore().getAt(rowIndex));
}
}]
}
]
});
rowEditing.on({
scope: this,
afteredit: function(roweditor, changes, record, rowIndex) {

//var obj = Bancha.getModel('Campaign');
//obj.save();


var o = roweditor.record.data
Bancha.RemoteStubs.Campaign.update(o,function(result){
console.log(result);
});
}
});
});
});

Dumas
2 Feb 2012, 5:24 PM
Hi!

You're doing things way to complicated.

You ONLY use Bancha.RemoteStubs when you want to use exposed controller methods, for standard CRUD functions use the record directly.



Bancha.onModelReady('Campaign', function() {

// create a normal store with a bancha model (everything is already configured in the model)
var store = Ext.create('Ext.data.JsonStore', {
model: Bancha.getModel('Campaign'),
});

// now load the data
store.load();

// --------------------------------------------------------
// stuff below is just standard extjs code
// --------------------------------------------------------

var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToMoveEditor: 1,
autoCancel: false
});

Ext.create('Ext.grid.Panel', {
...
handler: function(grid, rowIndex, colIndex) {
loadPageGrid(grid.getStore().getAt(rowIndex));
// I can't see where you have defined this function
}
}]
}
]
});
rowEditing.on({
scope: this,
afteredit: function(roweditor, changes, record, rowIndex) {

// just save the record
record.save({
success: function() { console.info('saved to server'); }
});

}
});
});
});



best regards
Roland

systematical
3 Feb 2012, 9:01 AM
^ Much easier, thanks.

betolima
5 Mar 2012, 6:00 AM
Guys, anyone could make available for download bancha done with a project so that we can study better?
So would be easier for us to understand all the file structures and models.
thank you

Dumas
5 Mar 2012, 6:11 AM
Hi!

Currently the project which includes all sample code is online here: https://github.com/Bancha/BanchaTestProject

That was the official part. I'm also working on a sample project for Integration with Sencha Designer, which you can find here: https://github.com/rolandschuetz/BanchaSampleProject
Warning: This is currently not fully working and also includes many work-around and fixes for Sencha Designer.

But actually you shouldn't need much more information than we already provide in the documentation:
On the extjs side you just need two functions:
- Bancha.onModelReady(modelNames,callback) to for async loading
- Bancha.getModel(modelName) if the model is already loaded.

On the server-side you just add the Bancha.BanchaRemotable behavior to cake models.

I'm currently very bussy with my job, but when I find some free time I want to provide a screencast and I'm also working on a new release.

If you have some specific questions I'm happy to help.

cheers
Roland

betolima
5 Mar 2012, 6:20 AM
ok Dumas, thank you very much.

squalo
20 Mar 2012, 10:50 AM
Hello
does this combination: extjs - bancha - cakePHP - MySQL
perhaps replace my approach using Ext.direct with those php query classes to access SQL data?

In fact I got problems to realize a 'hasmany' relationship this way using Ext.model and Ext.direct api.
Is this easier done including bancha and cakePHP?

(Pls excuse, if this question is a bit greenly, but I'm encounting cakePHP the first time.)

regards

Dumas
20 Mar 2012, 11:47 AM
Hallo!

HasMany is currently working very limited in ExtJS currently, so Bancha can also only support basic operations.


Bancha and CakePHP will provide you with a lot of out of the box solutions. CakePHP is a PHP-Framework (like Symfony) which makes it very easy to do all kinds of standard functions, like validating data, saving data, etc.
Checkout some of the CakePHP tutorials to get an idea of what it is doing. If you are new to PHP, I can tell you in the long run you definitely want to use a Framework. Most famous are Symfony, Zend Framework, and then CakePHP ;-)


In the next two or three days there will be a major release, but I can't say too much yet...

Dumas
26 Mar 2012, 9:55 PM
Bancha becomes dual-licensed and gets a lot of new features:

Sencha Touch Support
File Uploads
Expose any controller method
Lots of refactoring and bug fixes
API-Viewer for JS Developers (https://github.com/Bancha/BanchaDeveloperRemoteApi#readme)
I also added a introduction screencast.

http://banchaproject.com

Best regards
Roland

pierzu
29 Mar 2012, 5:18 AM
How i can assiociate data with foreign keys now?

pierzu
29 Mar 2012, 5:27 AM
I also recommend to change 45 line in BanchaApi.php file for:


if(array_key_exists('Bancha.BanchaRemotable', $model->actsAs)) {

Original line is not working in case, when you add something in your main appmodel, and additionaly something in each models.

Dumas
30 Mar 2012, 10:29 AM
Hello pierzu!


How i can assiociate data with foreign keys now?
I don't understand your question exactly. If you define CakePHP associations in your CakePHP model Bancha will automatically map these to Bancha.
This currently works only with default foreign keys, but will be working with everything in the final 1.0 release.


I also recommend to change 45 line in BanchaApi.php file
Thank you, you are right. It's updated.

Best regards
Roland

pierzu
2 Apr 2012, 4:39 AM
For example, i have two tables, "users" and "groups".

Users table fields : id, hid, name, group_id
Groups fields : id, hid, name

Ofc exisiting foreign key, model association.

I'm creating grid, connected to model User, so i have columns: id, hid, name, group_id.

1. How i can show Group.name instead of User.group_id?
2. How i can change that Bancha will not get users'id field and how i can change main key for hid? (hidden id)

My next problem, same tables, i have edit form for groups, where i see all group fields and grid, where are users, wchich belong to this group.

Grid is connected to model Group, and Bancha download all users. How i can send param like group_id, to show users, who are in this group?

Dumas
2 Apr 2012, 1:35 PM
Hello!


1. How i can show Group.name instead of User.group_id?
ExtJS is currently not supporting an convenient way for this, the ExtJS data model is missing any good solution.
So solutions are use case specific, about how much data are we talking about here? About row much rows for group and for user are you expecting? 10 groups, 1000 users?



2. How i can change that Bancha will not get users'id field and how i can change main key for hid? (hidden id)
Every record should always keep there id field in the model! Just don't display this field in the grid.

Why are you having id and hid? CakePHP expects the main key to always be named 'id'. Cake will not like this....


My next problem, same tables, i have edit form for groups, where i see all group fields and grid, where are users, wchich belong to this group.

Grid is connected to model Group, and Bancha download all users. How i can send param like group_id, to show users, who are in this group?
I'm not sure if I understood you correctly. I think your question was "How can I filter the loaded user-entries by group_id=XY?"
Do you want to create a new store each time or just load new data in an existing store?

best regards
Roland

pierzu
3 Apr 2012, 1:58 AM
ExtJS is currently not supporting an convenient way for this, the ExtJS data model is missing any good solution.
So solutions are use case specific, about how much data are we talking about here? About row much rows for group and for user are you expecting? 10 groups, 1000 users?


For example, as you said, 10 groups, 1000 users, what is the best solution?



Every record should always keep there id field in the model! Just don't display this field in the grid.

Why are you having id and hid? CakePHP expects the main key to always be named 'id'. Cake will not like this....


Ok, i know how to don't display id, but, if user will look at source, there will be all data. I want to avoid thtat, user will know record id's. I have id as primary int key, hid as id, wchich i want to display outside, in requests for example.



I'm not sure if I understood you correctly. I think your question was "How can I filter the loaded user-entries by group_id=XY?"
Do you want to create a new store each time or just load new data in an existing store?


Yes, i want to display only records, where group_id is equal to something. It could be filtering data after load, but better solution could be download data, wchich match my condition.

I want to create store for each group.

I have grid, where are groups, i click edit and i see two tabs form, first tab - form with group data, second tab - grid with group users.

Dumas
3 Apr 2012, 4:47 AM
Hello!

The cool thing about Bancha is, it will do everything in the background for you. So your questions are actually standard ExtJS questions. ;-)



For example, as you said, 10 groups, 1000 users, what is the best solution?
So if your associated grid (groups) is quite small there is no drawback in loading the whole store and then define a custom render in the grid. So define the custom renderer for User.group_id like this:

renderer: function(group_id) {
var rec = store.getAt(group_id);
return rec ? rec.get('name') : '';
}


Ok, i know how to don't display id, but, if user will look at source, there will be all data. I want to avoid thtat, user will know record id's. I have id as primary int key, hid as id, wchich i want to display outside, in requests for example.
I was about to write you some code for your solution... but it really looks wrong. Normally there is no security risk at all displaying the real id's and your solution with id & hid will create a lot of un-cakish code which you will soon wonder what you did... you might wanna chat with some guys on #cakephp.





Yes, i want to display only records, where group_id is equal to something. It could be filtering data after load, but better solution could be download data, wchich match my condition.

Bancha supports all filtering, so just filter your store before loading.


var filteredStore = Ext.create('Ext.data.Store',{
model: Bancha.getModel('Article')
});
filteredStore.filter('published',false);
filteredStore.load();


best regards
Roland

PS: You opened an Issue (https://github.com/Bancha/Bancha/issues/48) which seems to be jus misconfiguration, please add further details for resolving the issue.

Joel
4 Apr 2012, 3:29 AM
Okay, I must be missing something in this. Does this actually work with an Ext.Application style app? I've had a number of problems and I still can't get it to work. The error I'm getting is:

Uncaught Ext.Error: Bancha: Couldn't create the model cause the model is not supported by the server (no remote model)
Except this is a working Cake example so the model is definitely on the server and working. I had to change some other things as well, which is probably why I'm having issues.

1) I had to change the order of the scripts so that I load the bancha-api.js file first. Otherwise it complains that the Bancha namespace is missing. From looking at the code this makes sense in this order. How is it working for everyone else
2) I'm using Ext.Loader to load my files, but then Ext complains because the Bancha stuff is all in one file. I've been using ExtJs3 for the last couple of years, so I'm new to the ExtJs4 ways of doing things. I had to override Ext.Loader to ignore Bancha scripts.

I'm obvisouly missing something very fundamental. Is there an example implementation that actually uses the proper MVC architecture. The examples provided are just simple scripts loading a grid and aren't really meaty enough to get behind

Dumas
4 Apr 2012, 7:28 AM
Hello!

Bancha is definitely working, we are creating some big projects with it. It also works with an Ext.App-Style application.




Uncaught Ext.Error: Bancha: Couldn't create the model cause the model is not supported by the server (no remote model)
For two days we had a bug in the version on our website, please make sure in Bancha/Lib/Bancha/BanchaApi.php your line 52 looks like this:

if (array_key_exists('Bancha.BanchaRemotable', $model->actsAs) || in_array('Bancha.BanchaRemotable', $model->actsAs)) {
If the second condition is missing, add it and see if it works now. I expect this to be the problem ;)
If still now working please open /bancha/setup-check.html and if this is fine post the content of /bancha-api.js here. Sry for the inconvenience.


What else did you change? I'm curious. You shouldn't need to change the Plugin at all, so either there is an easier way or it's really a new feature and I will add the code to the general project ;)





1) I had to change the order of the scripts so that I load the bancha-api.js file first. Otherwise it complains that the Bancha namespace is missing. From looking at the code this makes sense in this order. How is it working for everyone else
Both ways should work. Our samples (http://samples.banchaproject.org) include the /bancha-api.js second. What's your error (file and line number).




2) I'm using Ext.Loader to load my files, but then Ext complains because the Bancha stuff is all in one file. I've been using ExtJs3 for the last couple of years, so I'm new to the ExtJs4 ways of doing things. I had to override Ext.Loader to ignore Bancha scripts.
It should be enough to tell Ext.Loader where it can find Bancha.



I'm obvisouly missing something very fundamental. Is there an example implementation that actually uses the proper MVC architecture. The examples provided are just simple scripts loading a grid and aren't really meaty enough to get behind
I was working on a Ext Designer Demo, but Sencha keeps changing the code-style of Designer so much that I will wait till the final release...

One implementation of MVC can be seen in the Bancha Sencha Touch Demo App (Sencha Touch uses the same MVC as ExtJS).
https://github.com/Bancha/BanchaTouchClient/blob/master/app.js

The simplest solution for MVC is
Already load all model definitions at start (that's totally fine if you have less then 50 models):
<script type="text/javascript" src="bancha-api/models/all.js"></script>
Before your Ext.Application definition just call:
Ext.onReady(function() { Bancha.init(); });
Now Everything is set up and every time you need a model you just call Bancha.getModel('ModelName');
Hope this helps. If you have further questions just ask here ;)

best regards
Roland

Joel
4 Apr 2012, 2:31 PM
Okay, adding the in_array fixed the problem. I only downloaded this the other day, so I'm not sure how I ended up with a different code base. I'll go back and re-download the entire plugin just to make sure.

I still have the loader problems. It's because of the writer.ConsistentJSON. It wants to extend Bancha.data.writer.JsonWithDateTime which Ext.Loader will try and load via a url (even though it's defined just above). This is probably an Ext.Loader issue, but how have you solved it?

If I put the code the other way around I get an error on this line:

REMOTE_API: Bancha.REMOTE_API
As this can't load Bancha yet as the other file defines the namespace. Thoughts?

Thanks for your speedy response, I like the concept and think it will be really useful once I've gotten over these issues.

Dumas
4 Apr 2012, 5:14 PM
Okay, adding the in_array fixed the problem. I only downloaded this the other day, so I'm not sure how I ended up with a different code base. I'll go back and re-download the entire plugin just to make sure.
I changed that line by trying to fix a problem (special usecase) like 3 days ago and with that broke the normal use case :/. Yesterday I finally fixed it^^



I still have the loader problems. It's because of the writer.ConsistentJSON. It wants to extend Bancha.data.writer.JsonWithDateTime which Ext.Loader will try and load via a url (even though it's defined just above). This is probably an Ext.Loader issue, but how have you solved it?
Ext.Loader loads stuff the first time you use it... but you always should need the Bancha singleton before you need the Bancha.data.writer.JsonWithDateTime. What part of your code is triggering this error?




If I put the code the other way around I get an error on this line:

REMOTE_API: Bancha.REMOTE_API
As this can't load Bancha yet as the other file defines the namespace.

True, error is easily fixed with this (will also be in the next version):


/* If remote api is already loaded, keep it */
REMOTE_API: window.Bancha ? Bancha.REMOTE_API : undefined,



Thanks for your speedy response, I like the concept and think it will be really useful once I've gotten over these issues.
Yeah! I think the plugin works really good. I figured the setup is still a bit hard... that's why I e.g. created the setup-check.... I'm planing to extent the Setup-Check with about twice as much tests to get first setups really smooth.... also working on nice internationalization-support for your apps ;)

best regards
Roland

hemanthks2012
10 Jun 2012, 12:28 AM
Can anyone tell me why Date is not in 'Created' Field in CRUD Example given on Bancha Official Website.

Even I am not able to configure in my localhost also.
Regards,

Hemant

Dumas
10 Jun 2012, 10:39 AM
Hello!

Oh, there was a small error, it only worked in Chrome. Thanks for the report.
Problem is fixed and in the current GitHub version (https://github.com/Bancha/Bancha) available.

Thanks
Roland

hemanthks2012
10 Jun 2012, 10:30 PM
Thanks for quick response Roland,

It is quite helpful.

evansLY
4 Jul 2012, 5:00 AM
I'm a huge CakePHP guy but really suck at JS. When I found ExtJS a long time ago I fell in love with it. However, at the time I didn't have an immediate need for it and honestly not the time to learn how to integrate it. Learned about Bancha in the past few days and thought all my wishes have come true.

Now, with that said. I've loaded up your TestApp and don't see a difference in how the pages are displayed, index, add, edit are all the same. I was thinking they would be like the examples off your site. So it has to be me. Does anyone have a complete package I can just extract to my web server, load the DB with test data and it just work in all it's glory so I can examine and learn from it?

What limitations are there currently with Bancha? I'd love to play with the Web Desktop, Simple Tasks, Calendar, Grid to Form and much more. Is it currently limited to mostly CRUD or are these examples also available?

Please help! I've got a new shiny toy and no batteries to make it work. :))

Dumas
4 Jul 2012, 6:31 PM
Hello, I'm glad you're interested :)


ExtJS is normally used in one page applications. So for everyone knowing ExtJSler it would be very strange to always reload pages after changes and only have one component per page. For these reasons Bancha does not automatically bake views for you.


ExtJS uses (like CakePHP) an MVC structure for the JavaScript code. Bancha now automatically creates all the models and configurations for data exchange for you. Now you would have to implement your own controllers and views.


Since we figured out that it is quite hard to create ExtJS grids and forms we are working scaffolding library which will be open source and completely free. (Just needs a bit of final testing before release)

You still would need to write a bit of JavaScript. Do you have any experience with ExtJS or JavaScript? Your use case is still interesting to me. What would be your perfect behavior of Bancha. I just thought it would be possible to create a second plugin which automatically scaffold all views with ExtJS. Would that be a practical solution or is that strange? Tell me more :D

best regards,
Roland

evansLY
6 Jul 2012, 2:11 AM
I do not know ExtJS and know very little JS.

I don't know, I guess bancha would have made things easier with components and maybe elements. Lets take a grid for example. Maybe an element that I I would

$this->element('Bancha.Basic_Grid' array($data,$extJS_Options));

extJS_Options could be a large array of all the different options available for a grid.
columns details for example
menuDisabled: true,
sortable: false,
xtype: 'actioncolumn',
width: 50

Basic grid would be something like
http://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/grid/array-grid.js

I guess that's my pipe dream. For now though could you post a cake project that is built to do show exactly how you did http://samples.banchaproject.org/crud-samples.html the gitHub project doesn't show any Bancha usage unless I'm overlooking something. Would just like to see some true code working so I can play and learn from it.

(http://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/grid/array-grid.js)

Dumas
2 Aug 2012, 8:32 PM
Hello

Bancha is right now written for people who understand ExtJS. It doesn't provide any custom CakePHP components and Elements, that is very un-ExtJSish. I'm planing to write a guide for CakePHP people without ExtJS experience, but that will take a bit.


The http://samples.banchaproject.org/crud-samples.html shows exactly the Bancha usage. Bancha extends the CakePHP part just to expose the data and all necessary CRUD methods.

The whole UI is created with JavaScript, so you can find the code here: https://raw.github.com/Bancha/BanchaTestProject/master/webroot/js/crud-samples.js
But since ExtJS is quite hard to first start, maybe you also want to take a look at http://scaffold.banchaproject.org/
This abstracts quite as you are looking for.

Best regards
Roland

Dumas
6 Aug 2012, 7:31 AM
Just added support for CakePHP 2.2

imafrikan
28 Aug 2012, 5:02 AM
Hi there, please this may be a noob question. But i cant figure out where or how i would use
Bancha.onModelReady(){}
In an MVC application

for example , would i initialize the models in my app.js below ?

Ext.application({
//requires: ['Ext.container.Viewport'],
name: 'Am',
appFolder: 'webroot/js/app',
controllers: [
'Users'
],
launch: function() {
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items:
{
xtype: 'userlist'

}

});
}
});


Or in my Controller ?


Ext.define('Am.controller.Users', {
extend: 'Ext.app.Controller',
stores: [
'Users'
],
models: ['User'],
views: [
'user.List',
'user.Edit'
],
init: function() {
this.control({
'viewport > userlist': {
itemdblclick: this.editUser
},
'useredit button[action=save]': {
click: this.updateUser
}
});
console.log('Initialized Users! This happens before the Application Launch function is called');
},

editUser: function(grid, record) {
var view = Ext.widget('useredit');
view.down('form').loadRecord(record);
},

updateUser: function(button) {
console.log('clicked the Save button');
var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();


record.set(values);
win.close();
this.getUsersStore().sync();
}
});


I am confused as to what part should i use it.
Say i wanted to create a grid panel dynamically, at what point would i have to use Bancha.onModelReady(){}

thank you.

If someone can give a little example too, that would also help. Thanks

Dumas
28 Aug 2012, 9:39 AM
Hello,

if you are having under 50 models I would recommand you to include the Bancha API with
/bancha-api/models/all.js

This means that all model definitions are already loaded from the server. Now you don't need to use the asynchronous way and instead you can just use write your store definition like this and don't have to think about anything anymore:

Ext.define('MyApp.store.User', {
extend: 'Ext.data.Store',
config: {
model: Bancha.getModel('User')
}
});

Best regards
Roland

imafrikan
28 Aug 2012, 11:37 AM
Hello,

if you are having under 50 models I would recommand you to include the Bancha API with
/bancha-api/models/all.js

This means that all model definitions are already loaded from the server. Now you don't need to use the asynchronous way and instead you can just use write your store definition like this and don't have to think about anything anymore:

Ext.define('MyApp.store.User', {
extend: 'Ext.data.Store',
config: {
model: Bancha.getModel('User')
}
});

Best regards
Roland


Thanks Roland, I tried your suggestion, and i ran into some problems.

Please i am getting the following errors from console.

/Bancha/data/writer/JsonWithDateTime.js?_dc=1346182280931 (http://devbox/homehealthext/Bancha/data/writer/JsonWithDateTime.js?_dc=1346182280931) 404 (Not Found)
/bancha-api/models/all.js (http://devbox/homehealthext/bancha-api/models/all.js) 404 (Not Found)

Even though i have followed the installation instructions .

The wierd thing though, is that if i delete all my model classes in cakephp, the /Bancha/setup-check.html
returns Congratulations! You have successfully installed Bancha.
But when i generate my model classes using bake,
the the /Bancha/setup-check.html returns

Load Bancha Remote API404: Could not load the Bancha Remote API
You most likely did not correctly installed Bancha, please check Installation: Step 2 (https://github.com/Bancha/Bancha/wiki/Installation) and make sure there are no cake errors in the Remote API (http://devbox/homehealthext/bancha-api.js).

Thank you.

Dumas
28 Aug 2012, 1:40 PM
Hello,

In your current installation you need to include:
devbox/homehealthext/Bancha/js/Bancha.js
devbox/homehealthext/bancha-api/models/all.js

If you are using Apache try disabling MultiViews, this could lead to a problem:
See https://github.com/Bancha/BanchaTestProject/blob/master/webroot/.htaccess#L20

If this doesn't work please open the remote api:
devbox/homehealthext/bancha-api.js

and (if you have a github account) post the issue to https://github.com/Bancha/Bancha/issues
otherwise we can talk here.

We should be able to fix that one ;-)

Best regards
Roland

imafrikan
28 Aug 2012, 2:22 PM
Just wanted to say thank you, while i go try out your suggestions. Thank you.

Dumas
28 Aug 2012, 2:33 PM
No problem ;)

imafrikan
28 Aug 2012, 3:05 PM
Ok i have been able to solve one problem.

/bancha-api/models/all.js (http://devbox/homehealthext/bancha-api/models/all.js) 404 (Not Found)

This Error is caused if you have not yet baked your controller.

But i am still having this problem.

/Bancha/data/writer/JsonWithDateTime.js?_dc=1346182280931 404 (Not Found)

(http://devbox/homehealthext/Bancha/data/writer/JsonWithDateTime.js?_dc=1346182280931)I followed your suggestions above i.e I disabled Multiviews in Apache2, I triple checked my include statement in my default layout.

Thank you.

Dumas
28 Aug 2012, 3:58 PM
...
This Error is caused if you have not yet baked your controller.

Oh, yes. This is actually not a bug, but there should be a usefull debugging error message for this case. There's already a https://github.com/Bancha/Bancha/issues/78 for that, should be solved in the next release.


About your second problem:
/Bancha/data/writer/JsonWithDateTime.js?_dc=1346182280931 404 (Not Found)
This request is triggered by the ExtJS dependency loader and means that the JsonWithDateTime writer is not available. This is defined in /Bancha/js/Bancha.js

So there is some script inclusion error. Please try opening /Bancha/js/Bancha.js directly in your browser and see what error you get. Can you post that here.

Thanks
Roland

vpetrunov
5 Sep 2012, 4:27 AM
are there plans for Bancha to support relations between models?

alexleandrom
9 Sep 2012, 10:10 PM
Hi,

I m using this Bancha, it s look very nice, but I want to know if there is some way to create a store which return to me a specific query in database, because When I use Store only pass the model I received all record of some entity, I need to make a simple conditions: Get all eventos from client_id = x, where I can make this?

Dumas
19 Sep 2012, 1:11 AM
Hello guys,

sry for the late response, I just was on holiday and I finally got a little bit of color :)


are there plans for Bancha to support relations between models?
The models associations are already supported. Currently Bancha just does not yet add associated data in a model read request (in nested arrays). There are plans to support this soon.
Associations can be quite tricky, so I might help you more if you can give me your use case.



I m using this Bancha, it s look very nice, but I want to know if there is some way to create a store which return to me a specific query in database, because When I use Store only pass the model I received all record of some entity, I need to make a simple conditions: Get all eventos from client_id = x, where I can make this?
I'm currently working on this, so far I don't have a complete solution, bit it is quite good. If you use the filter-support branch (https://github.com/Bancha/Bancha/tree/filter-support) and add the following line to your cakephp controller index method you can remotely filter:


class UsersController extends AppController { public function index() {
$this->User->recursive = 0;
$this->Components->load('Paginator')->whitelist[] = 'conditions'; // allow Bancha to remotly filter
$users = $this->paginate();
$this->set('users', $users);


// provide a return value for Bancha requests
return array_merge($this->request['paging']['User'],
array('records'=>$users));
}
...
}

// and in extjs
var store = Ext.create('Ext.data.Store', {
model: Bancha.getModel('User'), // yes, that's all you have to do (proxy, fields. etc. is already configured)
});

// now filter and load
store.filter('client_id',x);
store.load();





Best regards
Roland

kalchas
2 Oct 2012, 1:26 AM
Hello guys,
i also had the same questions, so I followed this thread. I have made a store,
based on a bancha model and declared remoteFilter: true.
I tried your solution above, that is to embed the line

$this->Components->load('Paginator')->whitelist[] = 'conditions'; // allow Bancha to remotly filter

and filtered my store to a specific (property,value) pair.
Cakephp continued to retrieve all the results, without implementing any filtering.
So, with the help of firebug and cakephp documentation, I added the following lines to my controller.
My model-database table is named Person.

if (isset($this->params['pass'][0]['filter']))
{
$p=$this->params['pass'][0]['filter'][0];

$field='Person.'.$p['property'];
$val=$p['value'];
$people = $this->paginate('Person', array("$field LIKE" => "$val%"));
} else
$people = $this->paginate();
$this->set('people', $people);
return array_merge($this->request['paging']['Person'],
array('records'=>$people));


I am looking forward to the next version of Bancha.
Good work!!!

Dumas
3 Oct 2012, 2:16 PM
Hello kalchas,

Bancha's filter-support Branch support this, you shouldn't need the posted code. Are you sure you're on the filter-support Branch?
Check out this example of how it currently works:
http://filter-support-branch.banchaproject.org/associations-sample.html

Best regards
Roland

kalchas
4 Oct 2012, 1:02 AM
Thank you Roland, it works with the new branch.



Hello kalchas,

Bancha's filter-support Branch support this, you shouldn't need the posted code. Are you sure you're on the filter-support Branch?
Check out this example of how it currently works:
http://filter-support-branch.banchaproject.org/associations-sample.html

Best regards
Roland

kalchas
4 Oct 2012, 10:19 PM
Dear Roland,
are you going to support nested (associated) models in a future release?

Dumas
5 Oct 2012, 2:53 AM
Yes, it is planed for the 1.4 release

Dumas
7 Oct 2012, 5:34 PM
There've been a lot of new cool stuff in the last two weeks, check it out:

- an article how to use Bancha with Sencha Architect 2 (http://banchaproject.org/using-sencha-architect-2.html)
- a Blog Reader App (http://blogapp.banchaproject.org/app.html) showcasing how to use Authentification and Sencha Architect 2
- a new documentation
(http://docs.banchaproject.org/) - a new release (http://banchaproject.org/download.html), now supporting
- loading of associated records (http://sample.banchaproject.org/associations-sample.html) and
- remote filtering of stores
(http://sample.banchaproject.org/remote-filter-samples.html)
I hope you like it, and you're looking forward to a lot more new features coming up soon!

hemanthks2012
8 Oct 2012, 2:56 AM
Hi.

I have a CakePHP Model with many associations (hasMany and belongTo both). When I see store in firebug, it shows only hasmany associations not belongTo.

Can u please help to resolve this issue with some example of belongTo Releationship.

Regards,

Dumas
8 Oct 2012, 7:20 AM
Hello,

thanks for pointing this out, you're right. The default behavior of ExtJS belongsTo associations doesn't work so well. I have added a bit code to Bancha, now it works smoothly. Check out the updated samples (http://samples.banchaproject.org/associations-sample.html) and the code on github (https://github.com/Bancha/Bancha) or the package download (http://banchaproject.org/download.html).

Best regards,
Roland

hemanthks2012
14 Oct 2012, 9:57 PM
Hello Roland,

Your solution worked well.

Thanks for quick response.

Best Regards

qlc
17 Oct 2012, 5:34 AM
Any chance that you might be working on Bancha support for other PHP frameworks like Laravel?

Dumas
17 Oct 2012, 5:48 AM
Hello,


we are currently thinking about building Bancha for Symfony, so we would have the exact same JavaScript API and you could easily swap Symfony for CakePHP and vise versa.


Developing Bancha took us more then 1500 hours, which is a lot of time/money for a small startup like ours. So we are currently evaluating if we want to take this path, and how many people actually would like to use it. Would you be interested in a Symfony port as well?


Best regards
Roland

qlc
17 Oct 2012, 5:52 AM
Orginally we were going to use CakePHP for our latest project. But, Laravel is too compelling to not use. thanks for the reply.


All the best,
John.

kalchas
6 Nov 2012, 1:59 AM
Hi roland,

I started a project using cakephp,extjs and bancha. I baked all controllers using the bancha component. Then I made a grid with a row editor and I noticed that I couldn't save any record.

I compared the controller augmentation on the site and what bake made for me. None of these where right, in order to make my record saved.

So I modified the Bancha/Console/Templates/bancha/actions/controller_actions.ctp file, in particular the edit function like this:

Line 122:
from

if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
to

if ($this-><?php echo $currentModelName; ?>->save($this->request->data['data']['0']['data'])) {

I didn't check if a similar save action in the add function works.

Now works fine, though I realized that the proxy is by default configured with batchActions:false,
is that true?
Is it possible for batchActions:true???

Thanks

PS. I am using the latest build of bancha from git.

Dumas
7 Nov 2012, 1:20 PM
Hello!

You should not need to augment the baking code, I know a lot of people which are using it without problems (still there might be a bug, so let's figure it out). Can you open the Browser console and send me the request content to bancha-dispatcher.php when you click on the save. Also please add the java script code. Thanks.



Now works fine, though I realized that the proxy is by default configured with batchActions:false,
is that true?
Is it possible for batchActions:true???
I can see that the javascript comment wasn't very clear, so let me explain:

There are two ways to batch requests:
- Batch all requests of a particular action into one request, like {..., method:"save", data:[record1, record2,..]} (this is the store batchActions config)
- Batch all requests on the application level, like [{..., method:"save", data:[record1]}, {..., method:"save", data:[record2]}]

We are using the second approach which beside the advantage that there is actually more batching (different requests still gets batched together) it also best fits with cakes default behavior.

For this reason please do not change this, it is already configured in the optimal way.

Best regards
Roland

kalchas
9 Nov 2012, 3:00 AM
I am trying to make a grid, which includes columns from some related models.
As I don't get my models related with one request, the Bancha.getModel() doesn't satisfy my needs. Instead, I preferred to make a model in ExtJs, configured my proxy api, with Bancha.RemoteStubs.<Model Name>.[create,read,update,destroy], configure some more fields with persist false, and define these as virtualfields (runtime) in my controller in the cakephp backend.

I also modified the paginate function, making some left joins to the tables I need, so I could retrieve the data I want displayed.

I preferred not to use the renderer function of grid column, because the related models may have large sets of data, and I don't want to waste my client's memory, in that way.

Tell me, if I could use a better approach to my problem.

Regards,

Harry.

Dumas
9 Nov 2012, 3:52 AM
I am trying to make a grid, which includes columns from some related models.
As I don't get my models related with one request, the Bancha.getModel() doesn't satisfy my needs. Instead, I preferred to make a model in ExtJs, configured my proxy api, with Bancha.RemoteStubs.<Model Name>.[create,read,update,destroy], configure some more fields with persist false, and define these as virtualfields (runtime) in my controller in the cakephp backend.

When you use the CakePHP Model::virtualFields config Bancha does everything for you :)



I also modified the paginate function, making some left joins to the tables I need, so I could retrieve the data I want displayed.
Can you send me your CakePHP find config, so we can find a way eigther Bancha can already do this or how to extend Bancha. Our goal is the Bancha handles (almost) every use case.




Tell me, if I could use a better approach to my problem.
Please tell me a little more, either here in the forums or to support@banchaproject.org so I can help you find the optimal solution.

Best Regards
Roland

PS: Does the scaffolding already work for you?

hemanthks2012
24 Nov 2012, 8:47 PM
Hi Roland,

Back to basics, I want to render associated Data (only BelongsTo) so initial I used get[Model]() method of store in its datachanged event and override the values but it seems not working form me.

Can you please answer following queries:

1. Whether I should apply joins in CakePHP it self, If yes then give me an example to join 3 tables in [Which] functions of CakePHP (view or index)

2. What changes i should make in ExtJS code.

Regards,

Hemant

Dumas
3 Dec 2012, 6:27 AM
Hello Hemant!



1. Whether I should apply joins in CakePHP it self, If yes then give me an example to join 3 tables in [Which] functions of CakePHP (view or index)
In most cases when you have a belongsTo you simply want to load the two stores individually and then do e.g. in the renderer for Article.user_id: return Ext.StoreMgr.get('Users').getById(user_id).get('name');

You might want to use our scaffolding library, it does this for you. Check out the Article tab in the last example: http://scaffold.banchaproject.org/samples/



2. What changes i should make in ExtJS code.

I'm not sure what exactly you want to do, if above doesn't help, please provide some more information (why do you want to join 3 things?, how are they connected, what do you actually want to display (a dataview, form, grid,....)).

Best regards,
Roland

Dumas
31 Dec 2012, 9:45 AM
The new year is coming. Time to plan Banchas next features!

What features would you like Bancha to get in the new year?

Happy new Year, or as we say here in Austria: Guten Rutsch!
Andreas, Florian, Kung and Roland

Dumas
19 Mar 2013, 11:38 AM
A new version of Bancha is out, including i18n support and a lot more. Check it out:
http://banchaproject.org/download.html

gaquaytomsk
21 Mar 2013, 1:26 AM
Thank you, Dumas

Bancha is such a great plugin. I love it so much.

But I have a problem and need your support.

I write a function, which search records of a model. How can I return record as a model (like CURD) so that I can display them in a Ext.grid.Panel with pagination?

I find out a method store.filter() but it's not strong enough. I need to search on the server side and return result to the store.

Please give me a help.

Dumas
21 Mar 2013, 3:51 PM
Hello,

Bancha supports this out of the box.

To perform the store.filter('field','value') on the server you only need to set the store's remoteFilter property (http://docs.sencha.com/ext-js/4-2/#!/api/Ext.data.Store-cfg-remoteFilter) to true.

An example can be found here:
http://samples.banchaproject.org/remote-filter-samples.html

Best regards
Roland

gaquaytomsk
24 Mar 2013, 5:10 AM
Thank you Dumas,

With Roland Schutz's help, I tried to modify the index() function with request's params, and it works pretty well.


Hello,

Bancha supports this out of the box.

To perform the store.filter('field','value') on the server you only need to set the store's remoteFilter property (http://docs.sencha.com/ext-js/4-2/#!/api/Ext.data.Store-cfg-remoteFilter) to true.

An example can be found here:
http://samples.banchaproject.org/remote-filter-samples.html

Best regards
Roland

izyx
22 May 2013, 5:38 AM
Hi, is it possible with bancha to load a grid with associated data from a hasOne association? Let's say I have a Company with one Address and I want to show a grid with the names of the Company(s) and the fields from the Address model in one row.

How would I set that grid up in ExtJS 4 with Bancha? Ik have the associations setup in CakePHP and if I look in the console at bancha-dispatcher.php I can see all the associations when Bancha is loading the model Company. From the MySQL logs I can see that de query is done with the join on the table holding the addresses so this looks right on the CakePHP/Bancha side.

But when I load the model by Bancha.getModel('Company') it won't load the associated model Address. So what am I missing?

Marcel

izyx
22 May 2013, 6:22 AM
OK, I think I have found it. I baked the controller before I put this association in the model. The controller is just loading the data from the Companies tables without the associated Address model. I was thrown off by the bancha-dispatcher because the first time it's called it is just retrieving the metadata and that's when it is showing the right associations.

Strange that the MySQL logs show the right query though.

I will recreate the controller, see if that solves it and post back with the results.

Dumas
22 May 2013, 6:31 AM
Hello Marcel,

you have touched a variaty of topics, so let me split them up:

- Loading of the MetaData as first request:
If you include the Bancha-API with /bancha-api/models/all.js the metadata is already included and this request will not be made.
- Association support:
Bancha understands associations, you don't need to re-bake the controller, Bancha takes the current model configuration and shares the associations with the frontend.
- Nested Loading:
CakePHP loads the address data for your company, but Bancha does not yet send this data directly. This is our next feature on our Roadmap (http://banchaproject.org/documentation-roadmap.html) and should be available before you put your app online ;-)
Currently Bancha will load the associated data (in your case the addresses) in a separate request if you need them, see this example: http://samples.banchaproject.org/associations-sample.html
So you can use this in your development till the feature is ready.

Hope this clarifies things for you. Let me know if something is unclear.

Cheers,
Roland

izyx
22 May 2013, 6:48 AM
Thanks for the quick reply. It's clear to me now and I'll wait for the next release. Lots of other stuff to work on. This is just one grid that I want loaded this way ;-)

Thanks for the great plugin!

izyx
23 May 2013, 1:04 AM
Hi, I'm trying to setup Bancha MVC style but it gives me an error 404 not found on the ExtJS files. I've downloaded the Sencha Architect BlogApp application and that gives me the same error. It looks like a conflict with the app folders of Bancha and CakePHP.

ExtJS is looking for the files in app/store/Articles.js but if I open that folder in my browser it can not find it and gives me a CakePHP error that controller AppController::Store() is not found. If I go to check with setup-check.html everything is fine.

ExtJS version is 4.1.1a GPL, version of CakePHP is 2.3.5 and Bancha is the latest release.

Edit: Can confirm that this is the same with ExtJS 4.07 and CakePHP 2.2.4

ShashankaN
3 Jun 2013, 9:24 PM
Im making a solution with Bancha, ExtJS and cakePHP here: https://github.com/FlyinPanda/DiabitiesCamp

H (https://github.com/FlyinPanda/DiabitiesCamp)ope some of you would like to contribute :)

Dumas
4 Jun 2013, 6:27 AM
Hello izyx,

sorry, I missed your posting in the first place. The BlogApp needs to be updated to Sencha Architect 2.2. In the last two month we worked on a big project with Bancha and didn't had enough time to work a lot on Bancha, but we have some cool new features in the pipe line. I hope we can get them out soon.

In the meanwhile check out http://banchaproject.org/using-sencha-architect-2.html

I'm write you, when the BlogApp is updated.

Cheers,
Roland

Dumas
4 Jun 2013, 6:29 AM
Hello ShashankaN,

sounds like a cool project! Do you have a demo link?

Cheers
Roland

izyx
12 Jun 2013, 10:32 PM
Just to let you know. I got it working by changing the app folder to a different name in app.js with appFolder: [your_dir_name]

Marcel

Dumas
13 Jun 2013, 3:14 AM
Great. Sorry for the inconvenience.

Dumas
1 Jul 2013, 4:28 AM
We are really happy to announce that we will soon be able to ship Bancha 2.0. A preview release will be available in the in the next two weeks.

Read more on the future of Bancha. (http://banchaproject.org/blog-entry/items/the-future-of-bancha.html)

Dumas
3 Aug 2013, 4:34 PM
Hello,

we just updated our Sencha Architect example, now providing a better ease of use and a better integration with Bancha, we also just packaged our second Bancha 2 preview release.

Read more about it here:
http://banchaproject.org/blog-entry/items/sencha-architect-integration.html

@izyx: Check it out (http://blogapp.banchaproject.org/app.html), now the example works flawless!

Best regards,
Roland

hemanthks2012
7 May 2014, 4:21 AM
Hi Roland,


I have been a great fan of of Bancha since 2012 and developed couple of applications with Bancha 1.0. Few days ago I started implementing Bancha 2.0 Basic but could not. I downloaded examples from git and tried to run in my local system. In Bancha 1.0 I have been using bancha-api.js with Bancha-API Declaration for Models. In Bancha 2.0, It shows that it is using /bancha-api-classes/models/all.js for models/controllers exposures. I want to declare this class directly. Can you provide any example for this class as it is not given with examples.

Thanks

Regards

Hemant

Dumas
7 May 2014, 3:08 PM
Hello Hemant,

great to hear!

To support Sencha Cmd we now provide a class-based solution. The old one is still supported at /bancha-api/models/all.js

I'm not sure what exactly you mean with I want to declare this class directly.
Do you want to declare the model classes yourself or what do you try to achieve?

Thanks,
Roland

Dumas
10 Jun 2014, 3:57 AM
Hello Hemant, can I help you?