本帖最后由 chin 于 2019-7-26 16:12 编辑
框架是asp.net core mvc。
flexgrid选择行的数据能不能不用js的JSON而是直接用form的post形式传到后台?
以下是后台经过js的JSON来获取的方法:- <form>
- <c1-flex-grid auto-generate-columns="false" id="Grid"
- selection-mode="ListBox"
- allow-sorting="false">
- <c1-flex-grid-column binding="Id"></c1-flex-grid-column>
- <c1-flex-grid-column binding="Group"></c1-flex-grid-column>
- <c1-flex-grid-column binding="Name"></c1-flex-grid-column>
- <c1-flex-grid-column binding="Flag"></c1-flex-grid-column>
- <c1-flex-grid-column binding="ComboboxList">
- <c1-data-map display-member-path="Name" selected-value-path="Code">
- <c1-items-source source-collection="comboboxList"></c1-items-source>
- </c1-data-map>
- </c1-flex-grid-column>
- <c1-items-source source-collection="@list" />
- </c1-flex-grid>
- <button id="btn1" type="button" class="btn btn-primary btn-sm">post</button>
- </form>
- @section Scripts{
- <script type="text/javascript">
- $(document).ready(function () {
- var grid = wijmo.Control.getControl("#Grid");
- var list = []
- $('#btn1').on('click', function () {
- var $this = $(this);
- var list = [];
- var test = "";
- var rows = grid.rows;
- for (var i = 0; i < rows.length; i++) {
- if (rows.isSelected) {
- list.push(grid.rows.dataItem);
- }
- }
- $.ajax({
- type: "POST",
- contentType: "application/json",
- url: "/Test/Index2",
- data: JSON.stringify(list),
- dataType: "json",
- success: function (result) {
- },
- error: function (err) {
- }
- });
- return false;
- });
- });
- </script>
复制代码- public IActionResult Index1()
- {
- MasterService service = new MasterService();
- ViewBag.ComboboxList = service.QueryMasterList();
- ViewBag.List = DataService.QueryDataList();
- return View();
- }
- [HttpPost]
- [Produces("application/json")]
- public IActionResult Index2([FromBody]IList<DataEntity> list)
- {
- return View(list);
- }
-
复制代码
|