Hello all,
I have a grid bound to UltraDataSource. Each row of the grid contains data for one employee. Every column stands for one day. The row tag is set to a business object that contains some information about the employee and some properties to sort the rows properly. After initializing DataSource and grid rows everything looks fine.
Users should be able to add new rows to the grid, one new row for every employee. What is the best approach to solve this? I loop through the existing rows, and should add a new row for every employee (identified by the row tag). At this moment, employees can have different counts of rows (at least one).
I'm facing the following problems:
Do I missing something, or what is the best approach for my problem?
Thanks for any suggestions.
Markus
Hello Hristo,
yes that is what I do now, but instead of simple unformatted text info, I create the(global) tag object itself, before I add the row. In the RowAdded event I assign the object to the tag property.
Thanks for your help.
Regards. Markus
Hello,
If you want to add a tag to the new UltraDataRow, you should use the overridden method which takes two arguments:
ultraDataSource1.Rows.Add(true, new object[]{"Some text"});
in order to raise RowAdded event of UltraDataSource. This event will be raised before InitializeRowEvent of the UltraGrid, so you will be able to write there e.Row.Tag = “My Tag”; and when InitializeRowEvent of the UltraGrid is firing you will have a tag for your UltraDataRow associated with the initialized UltraGridRow. I hope that this meets your needs and is acceptable for your scenario.
Please let me know if you have any further question.
Hello Mike,
I tried just to give you some information around the basic problem. The software is a time collecting software and the user actions on the grid are complex. One part of this is to plan activities for employees. Therefore every cell in a row stands for one activity for a employee at a certain day. Because of employees can have N activities per day, users must add new rows to plan more activities (one additional row for a particular employee or one additional row for allemployees). The employee names are listed in column one (optionally grouped by department).
I guess, it's a very common scenario that rows have a tag, containing some additional data. Because grid rows are sorted independent of the UltraDataSource rows collection, the tag also contains some sort information. To achieve this, it would be nice if the Add-member of the rows collection can take a parameter for the row tag.
In the Initialize_Row event of the grid, it is a must, to have the row tag. Depending on the tag the row appearance is initialized.
Well, I just like to ask you if I miss something about providing / initializing the tag. It seems that I don't miss anything and I have to use one of the "bad style tricky" workarounds.
Final question: At the moment I use a form-global newRowTag variable. This variable is set as tag in the RowAdded event of the UltraDataSource. This event will always fired bevor the Initialize_Row event of the grid. Right?
Thanks. Markus
Hi Markus,
I'm afraid you lost me. I understand that you have a grid that contains Employee rows. And you are saying you want to add an additional Employee for every Employee that already exists? So you are trying to double the number of Employees? Is that right?
If so... what does the user have to do with it? You write "Users should be able to add new rows to the grid, one new row for every employee." So the user clicks a button and this creates a duplicate of each Employee or something like that?
None of this makes a lot of sense to me, so I get the feeling like there is a typo or some error somewhere in your post that is misleading me.
Maybe you are talking about adding child rows underneath the Employees? But adding a child row to each Employee all at once doesn't seem to make much sense, either.
I will try to answer your questions as best I can, anyway...
mac_swit said:UltraDataRow has no constructor with parameter for the row tag.
Correct. So you must add the row and then set the Tag.
mac_swit said:Using the Add method of the UltraDataSource rows collection, the Initialize_Row event of the grid is called. But the row can not be properly initialized without tag object.
What you could do is simply check to see if the row Tag is null, and if so, bail out of InitializeRow without doing anything.
Then, after you have added all of the rows you need and set all of the Tags on every row, you could cal grid.Rows.Refresh(FireInitializeRow) to re-fire the InitializeRow event for all of the rows.
mac_swit said:Using the RowAdded event of the UltraDataSource rows collection, the event args have no information to initialize the tag object either.
The RowAdded event passes you the row, so I guess you are saying that you don't have enough information from the row data to determine which Tag to use.
So another option you might consider is using an additional column in the UltraDataSource to store the data instead of using Tag.