Changing sort during runtime
Posted: Mon May 21, 2007 5:44 pm
I have a question regarding changing the sort during runtime.
I found a thread where someone suggested using the following:
I have tried this and am unable to make this work. Is there something that I am missing?
Here is a toned down version of my code block for simplicity sake:
The SortBuild function builds an ORDER BY clause that I have tried to alter the SQLCommand, but adding an ORDER BY clause doesn't alter the appearance of the data. It is possible that I am doing something incorrect, but have been unable to determine what it could be. The BuildWhereClause function is working correctly and curiously it is performing a similar action as the SortBuild. I have commented out the SortBuild function until I am able to get something to work.
I have no preference as to how to get the sort ability to work, whether I alter the SQLCommand or whether I use the built-in Sort of the StiDataBand.
I noticed that I instantiate bndPreview, then change the Sort, then use the name to reference which DataSource to use for tsPreview. But no where do I add it to the report itself. What am I missing here? Please help. Thanks.
I found a thread where someone suggested using the following:
Code: Select all
To change sorting see below:
DataBand1.Sort = new string[2]
{
"ASC",
"Name"
};
Here is a toned down version of my code block for simplicity sake:
Code: Select all
Stimulsoft.Report.StiReport rptPreview;
Stimulsoft.Report.Components.StiDataBand bndPreview;
Stimulsoft.Report.Dictionary.StiSqlSource tsPreview;
rptPreview = LoadReport(_reportID);
bndPreview = MasterDatabandGet(rptPreview); //Retreives the Master databand for the loaded report
bndPreview.Sort = new string[2]
{
"DESC"
,"WorkOrderNumber"
};
tsPreview = rptPreview.DataSources[bndPreview.DataSource.Name] as Stimulsoft.Report.Dictionary.StiSqlSource;
// Need to pass WHERE and ORDER BY Clause
BuildWhereClause(ref tsPreview);
//SortBuild(ref tsPreview);
frmReportViewer frmX = new frmReportViewer();
frmX.MdiParent = this.MdiParent;
frmX.View(rptPreview, _reportID);
break;
Code: Select all
tsPreview.SqlCommand += " WHERE column = value "
tsPreview.SqlCommand += " ORDER BY column ASC"
I noticed that I instantiate bndPreview, then change the Sort, then use the name to reference which DataSource to use for tsPreview. But no where do I add it to the report itself. What am I missing here? Please help. Thanks.