jauno
  • jauno
  • Member Topic Starter
2016-01-22T16:29:53Z
Hello everyboy!
I have an iGrid with combobox cells. I store my cell data in a database therefore I need an ID to save. I now want to let chose an item of the cell combo and make a break in the BeforeCommitEdit event of iGrid to decide whether to save the data or not. (Thanks to Igor for fixing the crash problem at this point!)
To save the data, I want to read the ID of the item stored in the itemvalue of the cell combo.
In iGrid cells I also want to show celltext which is not member of the combobox listitems, therefore I must take the igCellTextCombo as ECellType Enumeration to enable this.
But now I have the problem to retrieve the value (=ID) of the choosen item. With igCellCombo I can get the the stored itemvalue (vNewValue in BeforeCommitEdit). With igCellTextCombo however while checking vNewValue I get the itemtext once more. My problem is to get the ID in this context. Look at the code added.
OK a way out of this would be to store the ID in a variable array while setting up the combo. But I can't find the index of the variable for iGrid cell combos have no selected item property.
How can I resolve the problem?

You can download the sample project here   but this works only with the new fixed iGrid >= v6.0.14 !!

lg Norbert
Igor/10Tec
2016-01-23T10:03:55Z
A good architectural question. Combo item values aren't used in BeforeCommitEdit for igCellTextCombo cells as the user can enter any text in the cell. How would you want to distinguish these two cases (selecting a combo item or entering an arbitrary string) in BeforeCommitEdit?

Tell us your vision, and perhaps, we'll implement it in the forthcoming service release of iGrid v6.
jauno
  • jauno
  • Member Topic Starter
2016-01-23T10:38:47Z
Originally Posted by: Igor/10Tec 


Tell us your vision, and perhaps, we'll implement it int he forthcoming service release of iGrid v6.



Hello Igor. This is very simpel. The iGrid cell combo has no listindex property as the vb combo has. The listindex returns the index of the item actually selected by the user. So the user can find the itemvalue/itemtext of the selected row in the combo an can handle this for db operations and so on. Actually this is not possible.

Igor/10Tec
2016-01-25T13:18:04Z
Why not possible? Your task is to find the combo item that has the item text equal to the text entered by the user, right? The ComboObject provides you with the indexed ItemText property that returns the text of the combo item with the specified index. You just need to enumerate all combo items using a loop from 1 to ListCount and find the corresponding item by querying the ItemText property for each item.
jauno
  • jauno
  • Member Topic Starter
2016-01-25T16:31:36Z
Originally Posted by: Igor/10Tec 

Why not possible? Your task is to find the combo item that has the item text equal to the text entered by the user, right? The ComboObject provides you with the indexed ItemText property that returns the text of the combo item with the specified index. You just need to enumerate all combo items using a loop from 1 to ListCount and find the corresponding item by querying the ItemText property for each item.



No that is not what I mean. My task is to find the index of the combo item selected or clicked by the user. Sure, I can capture the Itemtext in the BeforeCommitEdit event. But it could happen in theory that the ItemText is not unique. So this is not usable for database operations. Therefore I need an unique ItemValue as a second data which can also be stored as a property. OK so far. As I posted earlier I get both values when I interrupt in BeforeCommitEdit and celltype=igCellCombo. But as I want also to store data in the cell which are not equal with one of the combo items I must use celltype=igCellTextCombo to see all cell values. But then I have no chance to get the combo value.


Igor/10Tec
2016-01-26T09:28:08Z
Yes, now I see this "theoretical" problem - you may have the same text for different combo list items. Can I ask you just one question regarding this? How will your users distinguish items with the same text then?

Ok, in any case, I think your suggestion regarding the ability to retrieve the index of the selected combo list item in BeforeCommitEdit makes sense. I will think about adding this in the future releases.

Meanwhile, I've implemented a special tool based on the DevDbg method of iGrid that allows you to retrieve the value you need. The link to the interim build of iGrid with this tool is already in your mailbox.
Igor/10Tec
2016-01-26T09:30:48Z
One more question regarding the vNewValue parameter of BeforeCommitEdit. Do you find it right that this parameter contains the same text that will be stored as the cell text? Frankly speaking, I had not found another good candidate for this parameter value while working on iGrid v6.
jauno
  • jauno
  • Member Topic Starter
2016-01-26T19:00:00Z
Originally Posted by: Igor/10Tec 

One more question regarding the vNewValue parameter of BeforeCommitEdit. Do you find it right that this parameter contains the same text that will be stored as the cell text? Frankly speaking, I had not found another good candidate for this parameter value while working on iGrid v6.



I am a database programmer. Therefore I meanly think in those categories.
For database operations we distinguish between IDs (unique identifier to find and save the record in the db) an text (a description of the record which must not absolutely be unique). To save and restore a value from a combo to/from a db so it is essential to know the ID of the record. Therefore I think it is necessary to enable access to both properties in all circumstances.
jauno
  • jauno
  • Member Topic Starter
2016-01-26T19:15:46Z
Originally Posted by: Igor/10Tec 

Yes, now I see this "theoretical" problem - you may have the same text for different combo list items. Can I ask you just one question regarding this? How will your users distinguish items with the same text then?


That could be realized by storing unique identifiers in the value property of the combo.

Originally Posted by: Igor/10Tec 

Ok, in any case, I think your suggestion regarding the ability to retrieve the index of the selected combo list item in BeforeCommitEdit makes sense. I will think about adding this in the future releases.


Would be great! By the way: the MS combo and all other ones (3rd party) offer this option with its listindex property!

Originally Posted by: Igor/10Tec 

Meanwhile, I've implemented a special tool based on the DevDbg method of iGrid that allows you to retrieve the value you need. The link to the interim build of iGrid with this tool is already in your mailbox.



I'll look at it and report. And thanks a lot Igor for your extraordinary work for the iGrid users.
jauno
  • jauno
  • Member Topic Starter
2016-01-26T21:19:15Z
Originally Posted by: Igor/10Tec 


Meanwhile, I've implemented a special tool based on the DevDbg method of iGrid that allows you to retrieve the value you need. The link to the interim build of iGrid with this tool is already in your mailbox.


I tested it. It works. This is the answer to the problem to find out the combo item selected by the user. Thanks Igor.
Igor/10Tec
2016-01-27T08:00:01Z
Originally Posted by: jauno 

By the way: the MS combo and all other ones (3rd party) offer this option with its listindex property!



Yes, but there is one "small" problem. You are talking about the form controls, but in iGrid a ComboObject is an invisible object shared among many cells. ListIndex makes sense if you create an instance of the control on a form and the user selects 1 item in it, but in iGrid each cell with the same combo may have different ListIndex. In fact, we are talking more about a cell property.
jauno
  • jauno
  • Member Topic Starter
2016-01-27T20:51:14Z
Originally Posted by: Igor/10Tec 

Originally Posted by: jauno 

By the way: the MS combo and all other ones (3rd party) offer this option with its listindex property!



Yes, but there is one "small" problem. You are talking about the form controls, but in iGrid a ComboObject is an invisible object shared among many cells. ListIndex makes sense if you create an instance of the control on a form and the user selects 1 item in it, but in iGrid each cell with the same combo may have different ListIndex. In fact, we are talking more about a cell property.



I think the devdbg solution is sufficient enough to find the selected item. Will this be implemented in a sort of object property within the next major revision of iGrid?

Igor/10Tec
2016-01-28T09:06:50Z
My first idea was to pass this ListIndex value as a new parameter of the BeforeCommitEdit event.

An alternative solution can be implementing this as a cell property - say, CellComboListIndex(<row>, <col>). It could cache (store) the listindex of the selected combo item the last time, so you could retrieve this value at any time - not only in BeforeCommitEdit.

What is your opinion?
jauno
  • jauno
  • Member Topic Starter
2016-01-28T11:17:21Z
Originally Posted by: Igor/10Tec 

My first idea was to pass this ListIndex value as a new parameter of the BeforeCommitEdit event.

An alternative solution can be implementing this as a cell property - say, CellComboListIndex(<row>, <col>). It could cache (store) the listindex of the selected combo item the last time, so you could retrieve this value at any time - not only in BeforeCommitEdit.

What is your opinion?



I think the second solution would give more flexiblity to the programmer.
Igor/10Tec
2016-01-29T10:16:05Z
Ok, I have added this suggestion to the to-do list for the future releases.
Igor/10Tec
2017-03-22T13:52:30Z
We have built this functionality into iGrid 6.5 released today. First, the BeforeCommitEdit event was supplemented with the new parameter named lComboListIndex - it contains the index of the selected combo list item. Second, you can read the index of the combo list item selected in a cell after editing using the new CellComboListIndex property.