Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144279 | Apr 26,2019 08:49 PM UTC | May 9,2019 11:41 AM UTC | ASP.NET Core | 10 |
![]() |
Tags: Grid |
<ej-grid id="FlatGrid" allow-sorting="true" allow-paging="true">
……………..
<e-columns>
………………..
</e-columns>
</ej-grid>
<ej-script-manager></ej-script-manager> @*for non-unobtrusive mode, it must be given in partial view*@ |
mainPage:-
index.cshtml
<div class="control">
<ej-dialog id="editAttn" title="Attention Contacts" show-on-init="true" content-type="ajax" content-url="@Url.Content("~/Home/Text?OrderID=1").ToString()"></ej-dialog>
</div>
<ej-grid id="Grid" datasource=ViewBag.parent allow-paging="true">
<ej-grid query-string="EmployeeID" datasource="ViewBag.child">
<e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" edit-mode="Batch"></e-edit-settings>
<e-columns>
. . .
<e-column header-Text="Manage Records">
<e-column-commands>
<e-column-command type="button">
<e-button-options content-type="TextOnly" text="Edit" click="click"></e-button-options>
</e-column-command>
</e-column-commands>
</e-column>
</e-columns>
</ej-grid>
</ej-grid>
<script type="text/javascript">
function click(e) {
var id = $(e.target).closest(".e-detailcell").children().attr("id");
var childGrid = $("#" + id).ejGrid("instance");
var rowIndex = childGrid.model.selectedRowIndex;
if (rowIndex > -1) {
if (childGrid.batchChanges.added.length == 0) {
var curRow = childGrid.model.currentViewData[rowIndex];
if (curRow.OrderID > 1) {
$("#editAttn").ejDialog({ contentUrl: "/Home/Text?OrderID=" + curRow.OrderID});
$("#editAttn").ejDialog("open");
} else {
// to do err
}
}
}
}
</script>
Controller:-
public ActionResult Text(int OrderID)
{
ViewBag.OrderID = OrderID;
return PartialView("_datepicker");
}
partialView:-
_datepicker.cshml
<ej-grid id="FlatGrid" allow-sorting="true" allow-paging="true" action-begin="begin">
<e-datamanager url="//js.syncfusion.com/demos/ejServices/Wcf/Northwind.svc/Orders/?$top=45" offline="true" cross-domain="true"></e-datamanager>
<e-columns>
<e-column field="OrderID" header-text="Order ID" text-align="Right" width="75"></e-column>
</e-columns>
</ej-grid>
<script type="text/javascript">
var OrderID = @OrderID;
// this alert method has the correct orgId
alert("org from normal js: " + OrderID);
function begin(args) {
alert("in grid");
// this orgId is incorrect. It is always set to what it should have been last time
alert(OrderID);
args.model.query.addParams("OrderID", OrderID);
}
</script> |
uncaught exception: ej.Query: Custom Param is conflicting other request arguments f@https://localhost:44315/lib/syncfusion-javascript/Scripts/ej/web/ej.web.all.min.js:10:99778 addParams@https://localhost:44315/lib/syncfusion-javascript/Scripts/ej/web/ej.web.all.min.js:10:53642 batchRequest@https://localhost:44315/lib/syncfusion-javascript/Scripts/ej/web/ej.web.all.min.js:10:51990 saveChanges@https://localhost:44315/lib/syncfusion-javascript/Scripts/ej/web/ej.web.all.min.js:10:37215 _sendBulkReuqest@https://localhost:44315/lib/syncfusion-javascript/Scripts/ej/web/ej.web.all.min.js:10:3272557 batchSave@https://localhost:44315/lib/syncfusion-javascript/Scripts/ej/web/ej.web.all.min.js:10:3272470 _toolbarOperation@https://localhost:44315/lib/syncfusion-javascript/Scripts/ej/web/ej.web.all.min.js:10:3243651 _toolBarClick@https://localhost:44315/lib/syncfusion-javascript/Scripts/ej/web/ej.web.all.min.js:10:3240250 _trigger@https://localhost:44315/lib/syncfusion-javascript/Scripts/ej/web/ej.web.all.min.js:10:13795 _onItemClick@https://localhost:44315/lib/syncfusion-javascript/Scripts/ej/web/ej.web.all.min.js:10:1819262 t.proxy/<@https://localhost:44315/lib/syncfusion-javascript/Scripts/ej/web/ej.web.all.min.js:10:27682 dispatch@https://localhost:44315/lib/jquery/dist/jquery.js:4736:16 add/elemData.handle@https://localhost:44315/lib/jquery/dist/jquery.js:4549:6
I believe the problem is due to setting a parameter in the action-begin event of the grid:
var forgId = @fOrgId;
function GridBegin(args) {
args.model.query.addParams("FOrgId", forgId);
}
I commented out the method and hardcoded a "FOrgId" in the datasource and I was able to do batch updates. I think it is because I reopen the dialog and I am in fact trying to add the same parameter name more then once.
Is there a way I could do this?
var forgId = @fOrgId;
function GridBegin(args) {
if "FOrgId" parameter already exists {
change the value for the existing parameter
} else {
args.model.query.addParams("FOrgId", forgId);
}
}
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.