This is a migrated thread and some comments may be shown as answers.
Prevent duplicate rows inserted into Grid
3 Answers 134 Views
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 29 Oct 2010, 03:52 PM
Hello All,

I have a quite complex RadGrid with 3 hierarchy levels.
Data is show like below In RadGrid:

Organization1
   - SubOrganization1
        - SubSubOrganization1
Organization2
   - SubOrganization2
        - SubSubOrganization2
   - SubOrganization2B
        - SubSubOrganization2B
Organization3
   - SubOrganization3

Organizations are referenced in RadGrid using Ids. Every Organization has it's own Id, also Sub Organizations.

Now I have noticed a problem e.g. when I read data from Database which belongs to same Organization hive but are stored in different rows in Database. Right situation is like Organization2 in picture above, wrong one is sample below.

Is it possible to prevent inserting a row that allready exits in RadGrid using ItemCreated method and insert row in proper place in hierarchy?
I can get all Ids of Item in ItemCreated method but how to check from RadGrid that row or part of it doesn't allready exists and put childs after it?
Couldn't write such code I disn't get it to work, anyone have a sample?

I try avoid to create same first or second hiearchy level items but instead put their 3th level childs nicely below one hive (like Organization2 above).

Wrong hierarchy that I get now is like following where Organization2 is two diffrent hives:

Organization1
   - SubOrganization1
        - SubSubOrganization1
Organization2
   - SubOrganization2
        - SubSubOrganization2
Organization2 <=  This is wrong!
   - SubOrganization2B
        - SubSubOrganization2B
Organization3
   - SubOrganization3

Cheers

3 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 03 Nov 2010, 01:52 PM
Hi Mike,

The best option in my opinion would be do filter the data in order to return only distinct records from the data source. Is this not an option in your scenario?

Also, if you operate with the data of the current row, you should do it in the ItemDataBound event handler, as the row does not have any data in it in ItemCreated, this might have been the reason why your code did not work.

Sincerely yours,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mike
Top achievements
Rank 1
answered on 04 Nov 2010, 12:09 PM
Hello Tsvetina,

Okei, I removed duplicates in Data layer (I'm using .netTiers).
Found a Blog article which had a nice method to do it.

http://martinolivarespick.blogspot.com/2007/12/nettiers-select-distinct-method.html
 
Actually I assumed that RadGrid having nested GridTableViews to show Hierarchial data would have some automatic features to implement this. Or are there? I would really want to know that.

This should also be mentioned in Hierarchial RadGrid Samples if progmmer should him/herself remove duplicates.
There are quite many questions in Forum considering this issue.

Thanks,

Micheal


0
Tsvetina
Telerik team
answered on 09 Nov 2010, 02:42 PM
Hi Mike,

This is not a built-in feature of RadGrid, since it is not always a requirement not to show duplicate records. Also, it would be an unneeded performance load for the control to make it execute this logic, having in mind that it can be done without a lot of effort by the developer before the datasource is passed to the RadGrid control.

Kind regards,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Mike
Top achievements
Rank 1
Share this question
or