Seal Report Forum
»
Report Edition
»
Reports
»
Sort columns with Razor script
Rank: Newbie
Groups: Registered
Joined: 10/16/2015(UTC) Posts: 2
|
In my model I'm using a PostLoad Razor script to modify some columns after pulling the data from the database - this works great.
However, it messes up the sort order of the columns when they are displayed.
Is it possible to force a sort of a column in the UI after display via a Razor script? or to sort the data returned from the database after my script changes the data?
Thanks somehuman
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/20/2013(UTC) Posts: 1,209 Thanks: 14 times Was thanked: 206 time(s) in 199 post(s)
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 10/16/2015(UTC) Posts: 2
|
Good idea, but I'm getting the following error on the line: DataView dv = model.ResultTable.DefaultView;
Error in model 'model': Error when executing 'Post Load Script'. Object reference not set to an instance of an object.
My postload script is the default with the only addition of the line above: @using Seal.Model @using System.Data @{ ReportModel model = Model; ReportExecutionLog log = model.Report;
//Final script executed to modify the model result tables after its generation //Note that other assemblies can be used by saving the .dll in the Repository 'Assemblies' sub-folder... log.LogMessage("Modifying result values with the 'Final Script'..."); ResultTable summaryTable = model.SummaryTable; foreach (ResultPage page in model.Pages) { ResultTable dataTable = page.DataTable; ResultTable pageTable = page.PageTable;
/* e.g to change the last line of the Data Tables dataTable.Lines[dataTable.Lines.Count - 1][0].Value = "Maximum"; for (int i=0;i< dataTable.Lines[0].Length; i++) { string style = "background:orange;" + (i > 0 ? "text-align:right;" : ""); dataTable.Lines[dataTable.Lines.Count - 1][i].FinalCssStyle = style; } */ }
DataView dv = model.ResultTable.DefaultView; }
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/20/2013(UTC) Posts: 1,209 Thanks: 14 times Was thanked: 206 time(s) in 199 post(s)
|
I made a quick try on the sample report '01 Simple list': Code: DataView dv = model.ResultTable.DefaultView;
dv.Sort = "C3 desc";
model.ResultTable = dv.ToTable();
and it works fine ! can you check that your error does not come from somewhere else (looks like result table is null) ? Edited by user Sunday, October 18, 2015 1:14:02 PM(UTC)
| Reason: Not specified
|
|
|
|
Seal Report Forum
»
Report Edition
»
Reports
»
Sort columns with Razor script
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.