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

RadGrid Drag&Drop Header Problem

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gorgi Dimitrov
Top achievements
Rank 1
Gorgi Dimitrov asked on 21 May 2010, 07:15 PM
Hi,

I'm experiencing a problem with Telerik RadGrid v2010.1.309.35.

I have a control on which have two radgrids. For them I programmatically create columns with their properties. 
After initialization the control is showing correctly. Columns has their header text. But after I drag&drop items from one to another grid, the items has been dropped correctly, but the column headers has gone. I've try to solve this on many ways but I can't.

the html for my source grid is:
<telerik:RadGrid ID="rgSource" runat="server" AllowMultiRowSelection="true" ShowStatusBar="true" 
                          AutoGenerateColumns="false" EnableEmbeddedBaseStylesheet="true" ShowDesignTimeSmartTagMessage="true"  
                          EnableEmbeddedSkins="false" GridLines="None" Skin="TR" EnableAjaxSkinRendering="true"  
                          EnableEmbeddedScripts="false" EnableViewState="true" 
                          onneeddatasource="rgSource_NeedDataSource" onrowdrop="rgSource_RowDrop"  
                          onprerender="rgSource_PreRender"
                          <MasterTableView TableLayout="Fixed" Width="100%" runat="server"
                              <Columns> 
                                 
                              </Columns> 
                              <RowIndicatorColumn> 
                                  <HeaderStyle Width="20px" /> 
                              </RowIndicatorColumn> 
                              <ExpandCollapseColumn> 
                                  <HeaderStyle Width="20px" /> 
                              </ExpandCollapseColumn> 
                          </MasterTableView> 
                          <ClientSettings AllowRowsDragDrop="true"
                              <Selecting AllowRowSelect="True"/> 
                              <DataBinding EnableCaching="true"/> 
                              <Scrolling AllowScroll="true" UseStaticHeaders="true"/> 
                              <ClientEvents OnRowDropped="onRowDropping" /> 
                          </ClientSettings> 
                      </telerik:RadGrid> 

the html for the target grid is:
<telerik:RadGrid runat="server" ID="rgTarget" EnableEmbeddedScripts="false" 
                          AllowMultiRowSelection="true"  EnableEmbeddedBaseStylesheet="true" EnableViewState="true" 
                          EnableEmbeddedSkins="false" GridLines="None" Skin="TR" AutoGenerateColumns="false"  
                          onneeddatasource="rgTarget_NeedDataSource" onrowdrop="rgTarget_RowDrop1"  
                          onprerender="rgTarget_PreRender"
                          <MasterTableView TableLayout="Fixed" ShowHeadersWhenNoRecords="true" NoMasterRecordsText="" runat="server" > 
                                <Columns> 
                                  
                                </Columns> 
                        </MasterTableView> 
                        <ClientSettings AllowRowsDragDrop="True"
                            <Selecting AllowRowSelect="True" EnableDragToSelectRows="false"/> 
                            <DataBinding EnableCaching="true"/> 
                            <Scrolling AllowScroll="true" UseStaticHeaders="true"/> 
                            <ClientEvents OnRowDropped="onRowDropping" /> 
                        </ClientSettings> 
                    </telerik:RadGrid> 


the code for programmatic creation of the column is:
    GridClientSelectColumn clientSelectColumn = new GridClientSelectColumn(); 
                    clientSelectColumn.HeaderText = "ChkColumn"
                    clientSelectColumn.UniqueName = "ChkColumn"
                    clientSelectColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left; 
                    clientSelectColumn.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; 
                    //clientSelectColumn.HeaderStyle.Width = Unit.Pixel(25); 
                    rgSource.MasterTableView.Columns.Add(clientSelectColumn); 
                    GridClientSelectColumn client2SelectColumn = new GridClientSelectColumn(); 
                    client2SelectColumn.HeaderText = "Chk1Column"
                    client2SelectColumn.UniqueName = "Chk1Column"
                    client2SelectColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left; 
                    client2SelectColumn.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; 
                    client2SelectColumn.HeaderStyle.Width = Unit.Pixel(25); 
                    rgTarget.MasterTableView.Columns.Add(clientSelectColumn); 
 
                    GridBoundColumn boundColumn = new GridBoundColumn(); 
                    boundColumn.DataField = "SoftwareID"
                    boundColumn.UniqueName = "Software1ID"
                    boundColumn.HeaderText = "SoftwareID"
                    rgSource.MasterTableView.Columns.Add(boundColumn); 
                    GridBoundColumn bound1Column = new GridBoundColumn(); 
                    bound1Column.DataField = "SoftwareID"
                    bound1Column.UniqueName = "Software2ID"
                    bound1Column.HeaderText = "SoftwareID"
                    rgTarget.MasterTableView.Columns.Add(bound1Column); 
 
                    GridBoundColumn bound3Column = new GridBoundColumn(); 
                    bound3Column.DataField = "SoftwareName"
                    bound3Column.UniqueName = "Software3Name"
                    bound3Column.HeaderText = "SoftwareName"
                    rgSource.MasterTableView.Columns.Add(bound3Column); 
                    GridBoundColumn bound4Column = new GridBoundColumn(); 
                    bound4Column.DataField = "SoftwareName"
                    bound4Column.UniqueName = "Software4Name"
                    bound4Column.HeaderText = "SoftwareName"
                    rgTarget.MasterTableView.Columns.Add(bound4Column); 
                
                    this.rgSource.MasterTableView.DataKeyNames =  new string[] { "SoftwareID", "SoftwareName" }; 
                    this.rgTarget.MasterTableView.DataKeyNames = new string[] { "SoftwareID", "SoftwareName" }; 

the drag and drop code is:

                            List<Entities.SoftwareEntities.Software> targetSoftwarelist = (List<Entities.SoftwareEntities.Software>)Session["TargetDataSet"]; 
                            List<Entities.SoftwareEntities.Software> sourceSoftwareList = (List<Entities.SoftwareEntities.Software>)Session["SourceDataSet"]; 
 
                            for (int i = 0; i < tmpNumber; i++) 
                            { 
                                 
                                Entities.SoftwareEntities.Software software = new Entities.SoftwareEntities.Software(); 
                                software.SoftwareID = e.DraggedItems[i].GetDataKeyValue("SoftwareID").ToString(); 
                                software.SoftwareName = e.DraggedItems[i].GetDataKeyValue("SoftwareName").ToString(); 
                                sourceSoftwareList.Add(software); 
 
 
                            } 
 
                            // Reorder the rows in both grids 
                            targetSoftwarelist.RemoveAll(item => sourceSoftwareList.Find(sourceItem => sourceItem.SoftwareID == item.SoftwareID) != null); 
                            sourceSoftwareList.Sort((first, second) => first.SoftwareID.CompareTo(second.SoftwareID)); 
 
                            Session["TargetDataSet"] = targetSoftwarelist; 
                            Session["SourceDataSet"] = sourceSoftwareList; 
                             
                            rgSource.MasterTableView.GetColumn("SoftwareID").HeaderText = "SoftwareID"
                            rgSource.MasterTableView.GetColumn("SoftwareName").HeaderText = "SoftwareName"
 
                            this.rgTarget.Rebind(); 
                            this.rgSource.Rebind(); 

after drag and drop items, the column headers text  at both grids is gone. I've try to override the header text on drag and drop event but nothing happens. 

Also, after drag & drop the ColumItem Text doesn't render (Picture itemtext.png). This is big issue.

Actually guys, you have a bug on this forum, I've try to add new picture, the update mode gave me to, the picture has been uploaded but doesn't appear in attached files... ;) So you can't find the picture itemtext.png in attached files....

The screenshots are attached.

Regards,
Gjorgji Dimitrov


1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 26 May 2010, 08:30 AM
Hello Gorgi,

The issue you are facing is caused by incorrect column creation. When column are created after the LoadViewState stage is completed, they should be first added to the columns collection and then have  their settings modified. Please refer to this help article for more details.

Sincerely yours,
Rosen
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
Gorgi Dimitrov
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or