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

Problem with cell input on programmatically created columns

9 Answers 110 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nemanja
Top achievements
Rank 1
Nemanja asked on 06 Jun 2011, 10:50 PM
Hi there,

i'm having a strange issue with my gridview control in that when i set autogeneratecolumns to true and bind to a dataset, i am able to input values into cells and exit edit mode with the values still present in the cells but not so if i generate these columns programmatically.

i had to switch to programmatic cell loading because we need to load a dynamic list of columns to the grid based on user selections and so certain columns would only be added under certain conditions. however when i add a column to the grid, any input that i make in the cell just gets lost as soon as i exit edit mode.

this is how i create and add the gridviewdatacolumn:

GridViewDataColumn min = new GridViewDataColumn();
            min.UniqueName = "minCol";
            min.Header = "Min";
            min.FooterTextAlignment = TextAlignment.Right;
            min.TextAlignment = TextAlignment.Right;
            min.DataMemberBinding = new Binding("Min");
            min.DataType = Type.GetType("System.Int32");
            min.AggregateFunctions.Add(new SumFunction { SourceField = "Min"});
            radStoreGrid.Columns.Add(min);

what am i doing wrong? i've been sitting with this for over an hour and i just don't see the difference between this and the xaml declaration which worked fine...

thanks,
Nemanja

9 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 07 Jun 2011, 07:41 AM
Hello Nemanja,

 I have tried to reproduce the issue you reported, but I was not able to. May you take a look at the sample attached to verify whether my test corresponds to your requirements ? 

Regards,
Maya
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
Nemanja
Top achievements
Rank 1
answered on 07 Jun 2011, 10:27 AM
Hi Maya,

Thanks for the reply. I've had a look at the project you attached and it works ok on my machine, but it hasn't helped me to solve my problem.

The major differences between my application and this one are that I bind to a dataset and not an observable collection (although it was fine doing this without the programmatic creation of columns) and that i don't define any columns in the xaml at all, but do them all via a back end process that gets fired off by an event call (when a selection is made on another form).

the xaml for my grid looks like this:

<telerik:RadGridView x:Name="radStoreGrid" ItemsSource="{Binding StoreGridItems}"
                             VerticalAlignment="Top" Height="250" Margin="10,95,10,0"
                             IsFilteringAllowed="True" IsReadOnly="False" CanUserInsertRows="False"
                             ShowGroupPanel="False" ShowColumnFooters="True"
                             CanUserDeleteRows="False" AutoGenerateColumns="False"
                    
</telerik:RadGridView>

then i have a function that creates the columns and adds them to the gridview's columns collection in the code behind when another form completes the selection for the grid columns.

when i edit things in the view as per the screenshot below...



exiting the focus of the cell just blanks the value like this... (i had simply pressed enter to 'confirm')



in your examples you have some pre-defined columns in the columns collection already before creating the new one, is this in any linked to the problem maybe?
0
Nemanja
Top achievements
Rank 1
answered on 07 Jun 2011, 11:25 AM
Hi Maya,

i've done some further digging and i think i know what might be causing the  issue and why your example doesn't exhibit the same problem.

the difference in the two applications seems to step from the fact that the gridview element we're referencing is of different versions. the example you sent is v2.0.50727 while the one i'm currently using is v4.0.30319

what i've noticed is that when i set autogeneratecolumns to true on my grid, this works fine and each column's 'IsFrozen' property is set to false, whereas when i create it programmatically, 'IsFrozen' defaults to true. i've tried to simply change it in the code and set the property to false, but the setter seems to be inaccessible by default.

the question is then, how do i get around this? for some reason unless i opt to autogenerate my columns, i have no way of allowing the columns to be 'un-frozen'...

what can i do here?
0
Nemanja
Top achievements
Rank 1
answered on 08 Jun 2011, 03:05 PM
is there any solution to this?

i'm really stuck here and i need this functionality to deliver the project and i really don't know what i'm doing wrong or if there's a bug and how i can work around it?

i really need an urgent answer to this...
0
Maya
Telerik team
answered on 08 Jun 2011, 03:50 PM
Hello Nemanja,

Firstly, if the issue you experience cannot be reproduced with our current official release, I would definitely recommend you to upgrade to it. 
Considering the case, however, IsFrozen cannot be set neither in the code-behind, nor in xaml. You may set the FrozenColumnCount property of the grid. Furthermore, may you try to update the sample project I attached previously so that it follows your scenario and verify whether the same behavior can be reproduced ? If so, may you describe the steps I need to follow for changing the sample, thus keeping it as close to your project as possible ? 
 

Greetings,
Maya
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
Nemanja
Top achievements
Rank 1
answered on 08 Jun 2011, 07:14 PM
Hi Maya,

i have the Q1 2011 release of your dll's so i was under the impression that it was up to date. i'm using the .net 4 version of it so which install should i upgrade to and how do i do this?

i've tried to re-create this scenario in your project and it worked fine there. i wasn't using the dataset to bind to but the problem i've been getting happens when the autogenerate columns setting is set to false and the columns are set to frozen.

i've tried changing the FrozenColumnCount to zero but it hasn't fixed the issue.

Nemanja
0
Nemanja
Top achievements
Rank 1
answered on 08 Jun 2011, 08:29 PM
Hi Maya,

i've just checked the dll versions and there seems to be a discrepancy between the two versions. the sample app uses 2011.1.419.35 and my one is 2011.1.419.40.

i've looked at your latest release notes on the site and there isn't any mention of the two versions of the controls but either way, it seems like the issue i'm having wasn't present in the 35 edition but is now in 40.

Nemanja
0
Nemanja
Top achievements
Rank 1
answered on 10 Jun 2011, 04:20 PM
does anyone have an idea how to get around this? for some reason when i add columns programmatically it defaults the columns to be frozen and although i can go into editmode, any changes are discarded even if i confirm the change.

an older version of the dll's doesn't have this problem but the one that my company purchased does and i can't use the older ones coz they're just an evaluation version...

any help would be dearly appreciated.. i've been stuck on this for a few days now and there is a lot of pressure to deliver this functionality and i just can't get anywhere with it...
0
Maya
Telerik team
answered on 13 Jun 2011, 08:46 AM
Hello Nemanja,

In order to provide you with an appropriate solution, I really need to clarify the things a bit. Firstly, is the problem reproduced only when:
- working with DataSet;
- setting AutoGenerateColumn to "True" and defining the columns only in xaml;
- setting the FrozenColumnCount property of the grid.
On a side note, the difference between the version 2011.1.419.35 and 2011.1.419.40 is the .Net targeted version - the first one is for .Net 3.5, while the second one is for .Net 4. 

 
All the best,
Maya
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
GridView
Asked by
Nemanja
Top achievements
Rank 1
Answers by
Maya
Telerik team
Nemanja
Top achievements
Rank 1
Share this question
or