项目作者: SyncfusionExamples

项目描述 :
This is simple demo application to use the syncfusion ej2 component in partial view page
高级语言: HTML
项目地址: git://github.com/SyncfusionExamples/ej2-mvc-partialview.git
创建时间: 2018-10-19T07:20:08Z
项目社区:https://github.com/SyncfusionExamples/ej2-mvc-partialview

开源协议:

下载


Rendering Syncfusion ASP.Net Core UI Controls in MVC partial view page

This is simple demo application to use the syncfusion Syncfusion ASP.Net Core UI Controls in partial view page.

Solution

Follow the below steps to render Syncfusion ASP.Net Core UI (Essential JS 2) control in a partial view.

Create ASP.NET Core control using getting started

https://ej2.syncfusion.com/aspnetcore/documentation/button/getting-started.html

Created a partial view controls & Added the Syncfusion component to the partial view page

  1. <p>Use this area to provide additional information. </p>
  2. <div>
  3. <h3>Essential JS 2 Datepicker component</h3>
  4. <ejs-datepicker id="datepicker" placeholder="Choose a Date"></ejs-datepicker>
  5. </div>
  6. <br />
  7. <div>
  8. <h3>Essential JS 2 Timepicker component</h3>
  9. <ejs-timepicker id="timepicker" placeholder="Select a time"></ejs-timepicker>
  10. </div>
  11. <br />
  12. <div>
  13. <h3>Essential JS 2 Daterangepicker component</h3>
  14. <ejs-daterangepicker id="daterangepicker" placeholder="Choose a Range"></ejs-daterangepicker>
  15. </div>
  16. <br />
  17. <div>
  18. <h3>Essential JS 2 Dropdownlist component</h3>
  19. <div>
  20. <ejs-dropdownlist id="games" dataSource="@ViewBag.data" placeholder="Select a game" index="2" popupHeight="220px">
  21. <e-dropdownlist-fields text="Game" value="Id"></e-dropdownlist-fields>
  22. </ejs-dropdownlist>
  23. </div></div>

Added view bag data to the partial view control

  1. namespace PartialView.Controllers
  2. {
  3. public class HomeController : Controller
  4. {
  5. public IActionResult PartialPage()
  6. {
  7. ViewBag.data = new string[] { "Badminton", "Basketball", "Cricket", "Football", "Golf", "Gymnastics", "Hockey", "Tennis" };
  8. return PartialView();
  9. }
  10. }
  11. }

Create a div element for partial page controls

  1. <div class="row">
  2. <div id="PartialView"></div>
  3. </div>

Read partial view controls using Ajax:

  1. function clickAjax() {
  2. var ajax = new ej.base.Ajax('/PartialPage/index', 'GET', true);
  3. ajax.send().then(function (result) {
  4. var fragment = document.createElement('div');
  5. fragment.innerHTML = result;
  6. ej.base.append(fragment.children, document.getElementById('PartialView'), true);
  7. });;
  8. }