marat-gainullin / platypus-js

Apache License 2.0
9 stars 9 forks source link

ModelGridColumn with ModelCombo #69

Closed Level0r0s closed 8 years ago

Level0r0s commented 8 years ago

Example:

var modelCombo = new ModelCombo();
     modelCombo.displayList = model.owners;
     modelCombo.displayField = 'ownerName';

var g = new ModelGrid();
      g.data = model.allcustomers;
     var colService = new ServiceGridColumn();
     g.addColumnNode(colService);
     var colName = new ModelGridColumn();
         colName.field = 'name';
         colName.title = 'just added name column'

linking? colName with modelCombo

g.addColumnNode(colName);
form.view.add(g, {left: '300px', top: '10px', right: '9px', bottom: '48px'});
marat-gainullin commented 8 years ago

Assign column's property 'editor' to 'ModelCombo' instance just created. Additionally, combo columns have to be presentation of references, not scalars as 'name'. It should be 'colName.field = "owner";' (if "owner" is property of 'model.customers' array elements). Platypus.js ORM is able to automatically add reference properties based on foreign keys between model's entities. Note, that foreign key is one property in entity's data array and reference property based on it is another property. Names of reference properties is settled up with designer via a context menu of corresponding dash line between entities in module's model view.

marat-gainullin commented 8 years ago

Reference properties can be created by ORM as well as with your JavaScript code with wide variety of ways...

Level0r0s commented 8 years ago

in example PetHotel, OwnerView, no exist datamodel, model is passed by reference in runtime. (DATAMODEL is empty) ; for this reason. it is not possible to change Model GridColumn grdPets.petType to petTypesQuery

When I fill out ModelCombo.displayList property in ModelGridColumn grdPets.petType, this column does not list the petTypesQuery model. Does not accept that I write manually using the IDE Designer.

Solution: 1 in OwnerView.Datamodel, ADD petTypesQuery 2 chage ModelGridColumn grdPets.petType, ModelCombo.displayList to petTypesQuery 3 Save 4-1- in OwnerView.Datamodel, REMOVE petTypesQuery 5-SAVE

marat-gainullin commented 8 years ago

Can you clarify please what for do you change grdPets.petType.editor.displayList from data array of OwnersView's data model to another data array from OwnerView's data model?

marat-gainullin commented 8 years ago

Regarding your solution. It is quite well, but PetHotel example is organized so to avoid bunch of network requests (one for each OwnerView module instance). Pet types is commonly used data and so, it can be pulled from server only once.

Level0r0s commented 8 years ago

I did not change. For some reason, grd Pets.pet Type.editor.de playlist was empty. So I tried to replace and was not getting.

marat-gainullin commented 8 years ago

I've double checked just now examples work properly both on site and in fresh example project (new project -> Examples -> Platypus.js -> PetHotel) created via designer on local machine. There is data in form.grdPets.petType.editor.displayList in both cases.

May be all of this is another problem. Check please if your program calls model.requery(function(){}), and if database connection is properly configured and etc.

jskonst commented 8 years ago

Could you please share your project (github, archive, or some another way). Append database to the project (h2 for example) and its credentials - username and password. Using this materials we will be able to solve problems of your project.