This is a migrated thread and some comments may be shown as answers.

Simple Column Add Probleme

6 Answers 174 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Spoook
Top achievements
Rank 2
Spoook asked on 24 Jul 2008, 10:02 AM
Hi,

Like I said in my previous post I am testing (playing with) Telerik so I think I will have a couple of posts/threads here during the following weeks.

I put 2 RadGridViews on my form, and tried to add some columns to it. When I used the Property Builder, it was all good (except the fact that every time I clicked on a column (to delete it or something) it brought up the GeneralColumnSetting panel.. that was a little annoying when you want to add 30 columns and then delete 20 of them afterwards).

Now I tried to add some more columns to the grid from code. Here I started to have some problemes as follows:

1- using this
radGridView1.Columns.Add(myColumn);
or
radGridView1.MasterGridViewTemplate.Columns.Add(myColumn);
has the same efect, and I dont see the difference

2-Setting the column name is tricky:
            myColumn.HeaderText = "test1";
            myColumn.UniqueName = "name1";
            myColumn.FieldAlias = "alias1";
            myColumn.FieldName = "field1";
I found out that this is the order of what will be displayed. So if the HeaderText is not set, then the UniqueName will be set, if that is not set than the Field Alis will be set, and the FieldName is Column name for further referrence. So if the first 3 is not set than nothing will be displayed.

3-After deleting all the columns which I set from the Property Builder, I tried to set columns jut from the code.
Telerik.WinControls.UI.GridViewTextBoxColumn myColumn = new Telerik.WinControls.UI.GridViewTextBoxColumn();
            myColumn.HeaderText = "test1";
            radGridView1.MasterGridViewTemplate.Columns.Add(myColumn);
This simple code will not work, for my suprize (it worked before when I was adding columns to the ones I set before in the Property Builder). So I cheked the code generated by the Property Builder.
Here I found: myColumn.IsAutoGenerated = false;
IsAutoGenerated -cannot be found in the list of Intelisence... not nice.
But even setting everything like in the generated code, I still could not add Columns to my grid (the grid showed no columns at runtime).
I found out that you have to use:
((System.ComponentModel.ISupportInitialize)(this.radGridView1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.radGridView1.MasterGridViewTemplate)).BeginInit();
and of course the ending part as well to add Columns.
This is very strange, because you don't need to use this in your code (not in the generated one) when you have at least one column added from the Property Builer or added from code but using the "begin init, etc etc" stuff. So after adding at least one (1) Column to the grid you can use the simple grid.Columns.Add() method...

4 - I put two(2) RadGridViews to my form and created a Column like so:
Telerik.WinControls.UI.GridViewTextBoxColumn myColumn = new Telerik.WinControls.UI.GridViewTextBoxColumn();
            myColumn.HeaderText = "test1";
           
and added this to both of my Grids:
            radGridView2.Columns.Add(myColumn);           
            radGridView1.Columns.Add(myColumn);
First thing that I noticed is that it let me do this. Did not complained that I am adding one column to two controls. When I am asking for the owner grid (tru the template) it is the last Grid I added the column to.
The best part is still this: after running the application, when I try to resize the "test1" column in the second grid, it WILL NOT MOVE during the resize, but in stead the "test1" column in the first grid will show the change...spooky :)
The second grid, where I actually changed the column will not show the change until a forced refresh.

I believe that this is not a normal functionality to a grid and or columns.

I hope I get some answers from Telerik people for my posts. Thank you.

6 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 25 Jul 2008, 03:36 PM
Hi Spoook,

Up to your questions:

1. Actually, RadGridView.Columns and RadGrid.View.MasterViewTemplate.Columns refer to the same collection instance of columns. It is defined in the base DataAccessComponent class and is just exposed in the grid for convenience.

2. In the latest release - Q2 2008, this behavior is changed. The UniqueName property is the column name and the key of the column. This is the name for accessing columns from the columns collection and the name which is used in all sorting/grouping/filtering operations and expressions. The FieldName property is just mapping for bound data columns like DataPropertyName of MS DataGridView.

3. I'm not sure about your scenario, but I suppose that you add columns before initializing of the grid. The reason for the code to work before is that the serialized columns have been treated as explicitly added (not autogenerated). That's why after removing them, all columns you've added have cleared during the assigning of the data source. Please, check this problem again with the latest version (Q2 2008) and if it persist, write us back and give us more details about your scenario.

4. A column instance cannot be added to more than one grid at the same time - this is not allowed by design. Although it does not throw an exception, you shouldn't use such approach.

As to the behavior of the Property Builder in the structure window, we intend to improve it in future releases. However, the main idea is every time when a column is selected to show General Column Settings panel with the corresponding settings. If you have any ideas on how to make the Property Builder more usable, we'll be very happy to review them.


Kind regards,
Georgi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Spoook
Top achievements
Rank 2
answered on 28 Jul 2008, 02:08 PM
Hi,

  Thanks for the response,
now I have Q2.

issues:
1- ok, tnx
2- nicely resolved in Q2.. good work
3- the scenario is simple. Just create a gridview, with no columns, and add some columns from code. Normally you expect this code to work:
 private void Form1_Load(object sender, EventArgs e)
        {
            GridViewTextBoxColumn myColumn = new                Telerik.WinControls.UI.GridViewTextBoxColumn();
            myColumn.HeaderText = "header1";
            myColumn.UniqueName = "Name1";
            myColumn.FieldAlias = "alias";

            radGridView1.Columns.Add(myColumn);           
        }
But it does not. If you have problem understanding this issue, I can make a little movie for you :)
Note. the above code is for a simple wizard generated windows form application's Form1_Load event (in VS 2008, C#) with a RadGridView on the form (with no setup what so ever)

4- "A column instance cannot be added to more than one grid at the same time - this is not allowed by design" -> We don't know your design, and you know developers, if they can do/use something wrong, they will :). So you might want to take into consideration not to allow this, my opinion (or at least throw an exception that they need to handle -> to make people aware of this situation). Also I see that in Q2 you cannot add the same Column twice to one grid (this was allowed in the Q1 sp1), because of the unique name. Nice.
Still I think this a potentially big problem. For an example see the little movie from the link:
<admin>link removed for security and spam purposes. To attach files, please use the support ticketing system</admin>

Note that some of the delays in the movie are because of the software I am using for the screen capture.

Regarding the property builder, you can see from my movie that I moved the "GeneralViewSetting" panel to the right side. This way, when I add a new column or remove one, I don't need to change back all the time to the "Structure" panel, because it's still in focus.

Please see the following short movie:
<admin>link removed for security and spam purposes. To attach files, please use the support ticketing system</admin>

In the movie I mention a bug, where I cannot move the "General Column Settings" panel from the right side panel back to its original location.

Thank you and looking forward for some reply
0
Accepted
Georgi
Telerik team
answered on 31 Jul 2008, 06:40 AM
Hello Spoook,

About the problem with adding columns - previously I have tested the scenario adding some data (like in the "Unbound mode" example). This causes columns to be displayed.  If no data rows are added, the columns remain invisible which is a bug indeed. It will be fixed in the next release (Q2 2008 SP1).

As to the adding columns to two grids simultaneously, you're absolutely right. Indeed it is better if an exception is thrown when trying to add the column for the second time. We hardly could imagine a scenario when this could be intentionally or not done, so we have omitted the necessary protection. We'll change this in the future versions.

About the Property Builder, we reviewed carefully your movie. We agree that the Property Builder interface could be much improved and this task has been in our TODO list already for a long time. We'll consider your comments when redesign the whole visual appearance. Also we'll change the behavior of adding columns and General Settings pane. By the way, General Settings pane is defined as Tabbed document (instance of DocumentPane class) unlike the others which are Tool windows (instances of DockPanel class). That's why it does not react to right-mouse click and cannot be dragged to other panels. This is by design behavior and most probably it won't be changed. As to the layout of the panels - it has not been serialized properly and that is the reason to see "Structure" and "Advanced properties" panels on two tabs simultaneously. To reset the layout to the initial state, you have to find RadGridView_Docking.cfg file on your disk where the VS is installed and delete it. 
 
I hope this information was helpful! If you have any other comments, please don't hesitate to share them with us.

I have updated your Telerik points for the bug report and the movie show.

Regards,
Georgi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Spoook
Top achievements
Rank 2
answered on 31 Jul 2008, 11:21 AM
Hi

I marked you previous post as a potential answer to my questions, that these are indeed bugs.

I do have to make some correction to your post. The RadGridView_Docking.cfg file by default on a computer with XP on it will be found here:
c:\Documents and Settings\All Users\Application Data\Microsoft Corporation\Microsoft® Visual Studio® 2008\9.0.21022.8\RadGridView_Docking.cfg

For the problems regarding the General Setting panel and other Property builder issue I started a new thread, because this one is not about them, see here: http://www.telerik.com/community/forums/thread/b311D-bkdchd.aspx

I don't have any other questions regarding to the subject of this topic. However I don't really understand how should I proceed in the future with bug reports and stuff, because Jack told me to use support tickets in order to get the point for my reports (see http://www.telerik.com/community/forums/thread/b311D-bkceem.aspx) but twice now I got points just by reporting it here in the forum. I think the forum is a good place, so other people can see the issue as well.
So what should I do?
Second matter is about getting points. Here I reported two(2) bugs, I think somewhere important bugs, and I got 1000 points. So did I get 500 for each bug, or maybe 0 for one bug and 1000 for the other ? or this is a post-per  basis? If I report 10 bugs in one post I still get 1000?
(I am aware that the points earned for a bug report is 0-3000)

I would be happy if you could clear this for me.
Thank you
0
Vassil Petev
Telerik team
answered on 04 Aug 2008, 07:14 PM
Hello Spoook,

I have replied to some of your questions in the support ticket already.

On average, we award about 500 points per bug. The more the bug is a showstopper, the more points we award. The higher the points, the bigger chance that you will see a fix right in the next release.

In your case you got 2x500 points for each problem. If you report 10 bugs, you will get points to for each one, according to their severity.


Kind regards,
Vassil
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Spoook
Top achievements
Rank 2
answered on 05 Aug 2008, 08:31 AM
Hi,

Thank you for this clarification
I believe this thread can be closed

Take care
Tags
GridView
Asked by
Spoook
Top achievements
Rank 2
Answers by
Georgi
Telerik team
Spoook
Top achievements
Rank 2
Vassil Petev
Telerik team
Share this question
or