Rank: Newbie Coder Groups: Member
Joined: 12/5/2010 Posts: 12 Points: 36
|
Hi, I have to tables Branch and Employee. There is a one-to-many relationship between Branch and Employee. Upon code generation, WebOrb creates two ActiveRecords for Branch and Employee (with names Branch and Employee respectively). I have a datagrid as follows with DataGridColumn headerText="Branch" dataField="relatedBranch.branchname: There is a button to fill in the dataProvider with clikc even as follows: MyEnployees = ActiveRecords.Employee.findAll({PageSize:25}); The problem is when I click the button first time the Branch column with dataField="relatedBranch.branchname" does not show any value. But when I click it second time it is fetching the values and every thing works as expected. So how do I attain this on first click
Please help
|
Rank: Administration Groups: Administration
, Member
Joined: 9/10/2009 Posts: 320 Points: 778 Location: US
|
Hi, I think the following part of the WebORB documentation may help you: http://www.themidnightcoders.com/fileadmin/docs/dotnet/v4/guide/find_options.htmEspecially you should pay attention for the LoadRelations parameter. Regards, Cyril
|
Rank: Newbie Coder Groups: Member
Joined: 12/5/2010 Posts: 12 Points: 36
|
Hi, Cyril thanks for the tip, but unfortunately it is not working for me. (I'm using WebORB for Java but I assume the .NET documentation works for JAVA too.). The documentation says "The LoadRelations option works only in the direction from a primary key to a foreign key. This applies both to the one-to-many and the one-to-one cardinalities. Loading a 'parent' record (the one with the primary key) from a table which contains the foreign key is not currently supported.". In my case the Branch table is the master (parent) one Employee table is the child. So I think we can not load the relation "RelatedBranch" from ActiveRecords.Employee.
More over the findOptions.Sort = ["EmployeeName"]; ActiveRecords.Employee.findAll(findOptions) is not working. I was looking for the sort function though.
One thing would like to tell you is that when I call ActiveRecords.Employee.findAll() it is not showing the relatedBranch.branchname but when I call it second time it is fetching the values and is showing relatedBranch.branchname and every thing works as expected. What internal functions are happening there.
And can you tell me more about this loadChildRelation function.
Hmmm!!!! what if we create a view (SELECT b.branchname, e.employeename, e.employeecode FROM branch b, employee e WHERE e.branchid = b.branchid ORDER BY e.emplyeename) and put its ActiveRecord as the dataProvider for a DataGrid. Will it be automatically updated (RTMP, client sync) ?. WebOrb is useful to me only if it can provide me with RTMP service. I have no problem switching to your commercial service or enterprise edition.
Please help its rather urgent
|
Rank: Newbie Coder Groups: Member
Joined: 12/5/2010 Posts: 12 Points: 36
|
Hi,
Any help!!!!!!!!
|
Rank: Administration Groups: Administration
, Member
Joined: 9/10/2009 Posts: 320 Points: 778 Location: US
|
Hi,
could you please show me your database schema?
Regards, Cyril
|
Rank: Newbie Coder Groups: Member
Joined: 12/5/2010 Posts: 12 Points: 36
|
create table branch ( branchid int(10) unsigned not null auto_increment, branchcode varchar(8) not null, branchname varchar(32) not null, isavalcentre int(1) default 0, isawarehouse int(1) default 0, contactperson varchar(32), address varchar(64), city varchar(32), state varchar(32), country varchar(32), pin varchar(6), phone varchar(10), fax varchar(10), email varchar(24), url varchar(64), notes varchar(128), tag int(3) default 0, primary key (branchid), unique key (branchcode), unique key (branchname) ) engine=innodb;
create table employee ( userid int(10) unsigned auto_increment, username varchar(16) not null, password varchar(16) not null, cancreate int(1) default 1, canvalidate int(1) default 0, candespatch int(1) default 1, canwarehouse int(1) default 0, canviewallbranches int(1) default 0, employeename varchar(64) not null, code varchar(16), phone varchar(10), email varchar(24), notes varchar(128), tag int(3) default 0, branchid int(10) unsigned not null, index (branchid), primary key (userid), unique key (username), unique key (code), foreign key (branchid) references branch(branchid) on update cascade on delete restrict ) engine=innodb;
|
Rank: Administration Groups: Administration
, Member
Joined: 9/10/2009 Posts: 320 Points: 778 Location: US
|
azad_e_s,
one more thing. please share your code where are you trying to get entries with related elements.
Regards, Cyril
|
Rank: Newbie Coder Groups: Member
Joined: 12/5/2010 Posts: 12 Points: 36
|
[Bindable] private var MyUsers:ArrayCollection;
protected function GetUsers():void { MyUsers = ActiveRecords.User.findAll({PageSize:25}); }
|
Rank: Administration Groups: Administration
, Member
Joined: 9/10/2009 Posts: 320 Points: 778 Location: US
|
Please try the following: Code:
[Bindable] private var MyUsers:ArrayCollection;
protected function GetUsers():void { ... var findOptions:Object = new Object(); findOptions.PageSize = 20; findOptions.LoadRelations = [ "RELATED_PROPERTY_NAME" ];
MyUsers = ActiveRecords.User.findAll(findOptions); ... }
Please make sure that the name RELATED_PROPERTY_NAME is changed to your related property name
|
Rank: Newbie Coder Groups: Member
Joined: 12/5/2010 Posts: 12 Points: 36
|
I already tried that code and did again but no use. My related property name is "RelatedBranch". It is working on the second the click.What about this loadChildRelation function?
|