ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
can we use chef or country fields for example in the export grid to excel sheet demo?
Title:
B
I
{code}
?
can we use "forignkeys" fileds in the the gird (like Chef or Country for example) when we want to export the grid to excel sheet in the following demo http://demo.aspnetawesome.com/GridExportToExcelDemo cos i could not find these fields included in the example :) thank u very much in advance
Save Changes
Cancel
Kholoud
asked at 03 Feb 2016
yes, you need to add in BuildGridModel private method the Map = o => ... like in LunchGridController (copy and paste) and in ExportGridToExcel add "CountryName" to the columns array; you can also add the column in the view new Column { Bind = "Country.Name", ClientFormat = ".CountryName", Header = "Country" },
at 03 Feb 2016
Omu
thanks a looot ,well done but how to do it again for export All records to excel cos you dont use BuildGridModel function in this case so what the solution will be please :) thanks a lot in advance, great job :)
at 09 Feb 2016
Kholoud
for export all have these 2 lines in the controller method (ExportAllToExcel): var items = Db.Lunches.Select(o => new {o.Id, o.Person, o.Food, o.Location, CountryName = o.Country.Name}).ToList(); var columns = new[] { "Id", "Person", "Food", "Location", "CountryName" }; and replace next calls to "Db.Lunches" with "items"
at 09 Feb 2016
Omu
thanks a lot well done :)
at 10 Feb 2016
Kholoud
Hi again, hope ur doing well i was wondering if we can make "ExportAllToExcel" after Grouping or Sorting data is it possible or hard to code it thanks a lot
at 15 Feb 2016
Kholoud
in ExportGridToExcel action add this line as first: g.Paging = false;
at 15 Feb 2016
Omu
Answers
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK