Hi
i have a dataset that i am populating from database. this dataset gets two tables.
and i do it like this
dsExcel = new DataSet();dsFull = DataAccess.DataAccess.GetDataByFilters(filter1,filter2);dsExcel.Tables.Add(dsFull.Tables[0].Copy());dsExcel.Tables.Add(dsFull.Tables[1].Copy());
DataRelation dRel = new DataRelation("ParentChild", dsExcel.Tables[0].Columns["ID"], dsExcel.Tables[1].Columns["ID"]);dsExcel.Relations.Add(dRel);
ugExcel.DataSource = dsExcel;ugExcel.DataBind();
the first time it runs everything is ok , but each time i change the filter which gives it different parameters to the DataAccess it runs the code above again and again. what happens is that some of the columns order gets mixed up after the bind, and the grid columns order is not as the order in the dataset.
here is a screenshot (link because the add image in the infragistics forum does not work)
http://s1261.photobucket.com/albums/ii594/Sharon_Elihis/?action=view¤t=colorder.png
the top half of the screenshot shows the grid, sorry for masking. the left columns (in gradiant gray color) are in order, but the right side as you can see is not in order, they should be in order of numbers. these are not two seperate grid, it is one grid.
the bottom half of the screenshot shows the dataset, where you can see that the order of the column is as it should be.
in the grid i change the column caption(not key or columnname) to display the first part of the name meaning the two digits on the left of the ";" this does not effect anything except caption.
for now the way i have solved it is to bind the grid to null and then to the dataset as follows :
ugExcel.DataSource = null;ugExcel.DataBind();ugExcel.DataSource = dsExcel;ugExcel.DataBind();
this way it works ok. should i be handling this differently ?while i was able to solve this, i have a similar problem which has something to do with order of columns while exporting a similar grid to excel, not the exact same grid.for that grid i do the following :
i am populating 2 datatables (dtSummeryParent, dtSummeryChild) with data then :dsSummery.Tables.Add(dtSummeryParent);dsSummery.Tables.Add(dtSummeryChild);
DataRelation dRel = new DataRelation("ParentChild", dsSummery.Tables["SummeryParent"].Columns["SummeryID"], dsSummery.Tables["SummeryChild"].Columns["SummeryID"]);dsSummery.Relations.Add(dRel);
ugSummery.DataSource = null;ugSummery.DataBind(); ugSummery.DataSource = dsSummery;ugSummery.DataBind();
the grid displays the columns good (in the correct order) at the application side. but the problem happens when i try to export it. i use the UltraGridExcelExporter and in the BeginExport event i insert few empty columns to push some columns to the right so they will be alligned to the other grid (first grid) the way i want it to.
// insert empty columns for correct WW columns alignmente.Layout.Bands[0].Columns.Insert(1, "x1");e.Layout.Bands[1].Columns.Insert(1, "x1");
e.Layout.Bands[0].Columns.Insert(1, "x2");e.Layout.Bands[1].Columns.Insert(1, "x2");
e.Layout.Bands[0].Columns.Insert(1, "x3");e.Layout.Bands[1].Columns.Insert(1, "x3");
e.Layout.Bands[0].Columns.Insert(1, "x4");e.Layout.Bands[1].Columns.Insert(1, "x4");
e.Layout.Bands[0].Columns.Insert(1, "x5");e.Layout.Bands[1].Columns.Insert(1, "x5");
here is a link to a screenshot :
http://s1261.photobucket.com/albums/ii594/Sharon_Elihis/?action=view¤t=gridcolorderexl.pngon the top half of it you can see the "watch" window of the e.Layout.Bands[1].Columns.All where you can see that the order of the columns is correct.on the bottom half of the screenshot in the blue rectangle you can see that the x5-x1 is not in sequence and does not appear as in the watch window.
the red horizontal line seperates between the first grid which i've mentioned in the begining of the post, and the second grid which i am talking about now. the upper grid is being exported to excel with no issue, the lower one has the export issue.
here i dont have the option to do ...DataSource = null because this is in theBeginExportevent .
as a last resort i thought to add these x1-x5 columns to the real dataset and make it hidden, then in the export make it visible and when export completes to hide it again, but i hope you may have some input for me to check / apply, am i missing something?
i appologies this is such a long post but i had to give as much details as i could.
i encountered the same problem in a different grid export but this time setting the width += 1 or random value did not help.
finally i found another solution, after inserting the empty column, it needs to be Fixed and its VisiblePosition also needs to be set.
e.Layout.Bands[1].Columns.Insert(1, "x1"); e.Layout.Bands[1].Columns["x1"].Header.Fixed = true; e.Layout.Bands[1].Columns["x1"].Header.VisiblePosition = 1;
the order of the changes needs to be exactly like this, meaning
1. Insert2. Fixed = True3. VisiblePosition = X;
any other combination will not work, like switching between 2 and 3 .
Thanks Mike,
Tag didn't work but the width +=1 was indeed good idea :-)
thanks
I understand.
If setting the Width of a column is working around the issue, then it's probably because of some flag in the grid that is either being set or not being set improperly and setting the column width is either resolving that flag or setting it.
If you want to try to find a better workaround, then maybe try setting a property on the column that won't have any real effect on the export like CellDisplayStyle or Tag. Or maybe just add one to the column width instead of setting it to an arbitrary value.
Hi,
We try very hard to make sure everything is backward compatible. But the reality is that we do sometimes have no choice but to make breaking changes and we do make bug fixes all the time. So there's always a possibility that something may change or that your code might be relying on some behavior that was a bug and is now fixed.
Whenever we knowingly make breaking changes, we document them. In this case, I can tell you for certain that there will be at least one small breaking change in your application - we changed around the Excel dll's. So you will need to make a small adjustment to your project references just to get your application to run. But this is no big deal and if you use the Infragistics Project Upgrade Utility, it will do it for you.
The good news is that the versions of NetAdvantage can be installed side-by-side. So if you want, you could download a trial version of the latest version of NetAdvantage and try it out and it will have no effect on your existing NetAdvantage installation.