Serenity: Now...what to do with checked rows?

Created on 24 Apr 2016  路  4Comments  路  Source: serenity-is/Serenity

Hi community,

I am stuck at one thing.
I have implemented checkboxes to my grid.
image

Now when I want to click the button to "do something with selected rows", I come short of knowledge in this genius but somewhat implicit (coding) platform.

  1. I want to export the checked rows to Excel. Now the whole grid is exported when Excel is clicked.
  2. I would also like to perform some sql maneuvers with the checked items.

I suspect the solution to no. 1 is somewhere hidden in the Endpoint.cs where the Excel handler is.
But that is in the web project but selected rows are in the script project.

Regarding no. 2, can I call some LINQ procedure and have an SQL Trigger in my database handle what I have to do??

I would appreciate all suggestions on this matter.

Best,
Biggi

ps. I am aware of the sample code below:

image

Most helpful comment

Now for second question, see cancellable batch action sample under basic samples. It passes a list to a service endpoint, in your case this might be all checked IDs. Than do what you like in endpoint.

All 4 comments

You see onViewSubmit parameter that you give to ExcelExportHelper.CreateToolButton right. Now instead of returning this.onViewSubmit() in it, do like this:

ExcelExportHelper.CreateToolButton(this, 
                CustomerService.BaseUrl + "/ListExcel", () => {
if (this.OnViewSubmit()) {
     ((ListRequest)this.View.Params).Criteria &= new Criteria("SomeField").In(rowSelection.GetSelectedKeys());
     return true;
}
else
   return false;
}

gotcha?

Now for second question, see cancellable batch action sample under basic samples. It passes a list to a service endpoint, in your case this might be all checked IDs. Than do what you like in endpoint.

Hi and thank you for the quick reply.
The code sample was also well received.

I took it for a spin last night but did not succeed.
See my code with your suggestion below

protected override List<ToolButton> GetButtons() { var buttons = base.GetButtons(); buttons.Add(ExcelExportHelper.CreateToolButton(this, GreidaLanService.BaseUrl + "/ListExcel", () => { if (this.OnViewSubmit()) { ((ListRequest)this.View.Params).Criteria &= new Criteria("DEVICEID").In(rowSelection.GetSelectedKeys()); return true; } else return false; }));

Maybe you could see what is wrong with it but I get an error in a new window when using it.
image

When I replace .GetSelectedKeys to .In(rowSelection.GetSelectedKeys(() with .ToString(), then I get an Excel file only with headers though.

Any suggestions?

Best,
Birgir

No worries - Problem solved :)
On to the next one.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dudeman972 picture dudeman972  路  3Comments

GitHubOrim picture GitHubOrim  路  3Comments

Pinellus picture Pinellus  路  3Comments

gfo2007 picture gfo2007  路  3Comments

chintankukadiya18 picture chintankukadiya18  路  3Comments