Topic: New object property

Hello Dmitry,

The latest version of MVD now has many object properties to make development much quicker. 

Can I ask you to consider adding a "list" property (like in Excel, or Google Docs 'List of Items') where you can create a list of comma separated values and present them as a drop-down pick-list.

This would remove the need to create tables just to hold a small number of rows, remove the need to create relationships between the tables and remove the need to create additional display (tablegrid) and maintenance forms.  It would also be a lot easier for new Users.

On a project I am working on now, I have to add tables plus links and all of the forms for 12 comboboxes (see list1.jpg);  with a "list" property, I estimate it would only take me 5 minutes to set them all up.

I appreciate that some of MVD's features are always going to be of more interest than others but I think something like this would benefit almost everyone.  Some of us are now starting to create quite large projects and anything that reduces size and complexity has to be a good thing.

Thanks,
Derek.

Post's attachments

Attachment icon lists1.jpg 135.7 kb, 275 downloads since 2016-01-19 

Re: New object property

Hello,


Unfortunately what you have to suggest contrary to the proper database structure.
You can't use ComboBox without a relationship in database table.


May be will be better to make wizard which helps to create database table with prefilled records.

Dmitry.

Re: New object property

Hi Dmitry,
Understood and thanks for getting back to me.
I've managed to put together a bit of a work-around now that will be fine for most of the things I need to do.
Derek.

Re: New object property

Hello Derek,


Want to fill your Comboboxes with fixed values not coming from a table ?


Try this : I put it on the Onshow event of the form, but it's up to you


procedure Form1_OnShow (Sender: string; Action: string);
var
  StringList: TStringList;
begin
  StringList := TStringList.Create;
  try
    with StringList do begin
      Add('Monday');
      Add('Tuesday');
      Add('Wednesday');
      Add('Thursday');
      Add('Friday');
      Add('Saturday');
      Add('Sunday');
    end;
    with Form1.ComboBox1 do begin
      Items.Assign(StringList);
      ItemIndex := 0; //To set the combobox on Monday, but can be anything else, even -1 if you want it empty
    end;
  finally
    StringList.free;
  end;
end;

To get the selected element id, you can not use dbItemID because you're not filling the combobox with the content of a table.
Instead  use ItemIndex

Form1.ComboBox1.ItemIndex;

Let me know if this suits your needs.

Cheers


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: New object property

Hi Mathias,

I really like the script!  I'll copy my project and try it your way and compare the two approaches.

My own solution doesn't use a script at all.  I create multiple links to a single 'lookups' table and then put filters on each of the comboboxes.  It saves a lot of time (for my latest project, it is 4 forms instead of 14!).  And, of course, if new look-up values are needed, they can simply be added like any normal data.

Thanks for your interest and help - much appreciated.

Derek.

Re: New object property

Derek,
I have found you can also do the following. I had the same situation as you, where I wanted dropdown lists that were not connected to a database. It works and you can still use "dbItemId", if you want.   Just place these assignments in your Form OnShow event.

     Form1.Month_ComboBox.Clear;
     Form1.Month_ComboBox.dbAddRecord(-1,'');
     Form1.Month_ComboBox.dbAddRecord(1,'Jan');
     Form1.Month_ComboBox.dbAddRecord(2,'Feb');
     Form1.Month_ComboBox.dbAddRecord(3,'Mar');
     Form1.Month_ComboBox.dbAddRecord(4,'Apr');
     Form1.Month_ComboBox.dbAddRecord(5,'May');
     Form1.Month_ComboBox.dbAddRecord(6,'Jun');
     Form1.Month_ComboBox.dbAddRecord(7,'Jul');
     Form1.Month_ComboBox.dbAddRecord(8,'Aug');
     Form1.Month_ComboBox.dbAddRecord(9,'Sep');
     Form1.Month_ComboBox.dbAddRecord(10,'Oct');
     Form1.Month_ComboBox.dbAddRecord(11,'Nov');
     Form1.Month_ComboBox.dbAddRecord(12,'Dec');

Re: New object property

Hello EHWagner,

Thanks for the information.  I have tried the suggestions from Mathias and yourself and both work well;  it now gives me a couple of further options when writing new projects.
I don't actually have an objection to dropdown lists being connected to a database per se, simply the number of additional tables and forms you have to create and the time it takes for what is essentially an attribute (as distinct from a proper related record).
What I came up with in the end doesn't have any script at all and works entirely off 1 table and users are able to add new values to the various lists without me getting involved (which is always good news!).
I've attached a small demo based on the project that I first used this approach on - it's easier than trying to explain - but you can see all the 'dropdown lists' in their combo-boxes working on form2! 
If you can think of any improvements, please let me know (for example, I was trying to use this approach in conjunction with 'parent combo-boxes' but couldn't figure out a way that saved any time over doing it in the usual manner).
Derek.

Post's attachments

Attachment icon cardealership ehw.zip 495.84 kb, 500 downloads since 2016-01-22 

Re: New object property

Derek,
Your example is definitely an efficient way to consolidate comboboxes. I've done that with other software products. Your method is certainly the way to go in your specific project and would stick with it.

Re: New object property

Hello Derek,


I also had a look at your "concept" for comboboxes, and that clever indeed, really clever.


Maybe had a little code to avoid duplicates, or manually modify your database structure to had the UNIQUE constraint ?


But really clever ! be sure I'll keep that in mind thanks to you


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: New object property

Hello Mathias,
Thanks for your comments.
I thought about checking for duplicate entries but at the same time, I wanted a solution that didn't involve a script;  personally, I think duplicate checking is something that the core product could handle.
I have tidied up my 'lookups' approach (I now call it "attributes" - LOL!) and have created a simple .txt file that contains the generated code to create the 'attributes' forms and the generated code to create the 'attributes' table and as many relationships as my project requires. 
Now when I am creating a new project all I have to do is:
1.  copy and paste the relevant section into the tables.ini file  (I create 10 'attribute' look-ups by default)
2.  copy and paste the relevant section into the forms.xml file
It takes less than 60 seconds after which I have fully working forms, an 'attributes' table definition and all the relationships.  It is a big improvement on my productivity!
Hope some of this can be of help to you.
Thanks again for your interest.
Derek.

Post's attachments

Attachment icon MVD set up attributes.txt 25.89 kb, 691 downloads since 2016-01-25