- Home
- Forum
- ASP.NET Core
- Grid Inside Dialog
Grid Inside Dialog
<ej-dialog id="editAttn" title="Attention Contacts" show-on-init="false" content-type="ajax" content-url="@Url.Content("/Surface/Attention").ToString()"></ej-dialog>
</div>
if (args.itemName == "Attention") {
var childGrid = $("#" + this._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.IsPerson == false) {
if (curRow.ParentSurfaceContactId > 1) {
//var prDialog = $.templates($("#projRptDialog").html());
//$(prDialog.render()).ejDialog({ title: "Project Report", width: "710px" });
//editAttn
$("#editAttn").ejDialog({ contentUrl: "/Surface/Attention?orgId=" + curRow.ParentSurfaceContactId});
$("#editAttn").ejDialog("open");
} else {
// to do err
}
} else {
// to do err
}
} else {
// to do error msg
}
} else {
// TO DO error msg
}
}
}
var orgId = ViewBag.OrgId;
}
<ej-grid id="SurfAttnCon" allow-paging="true" allow-filtering="false" allow-resizing="true" allow-resize-to-fit="true" allow-sorting="false" allow-scrolling="true" allow-text-wrap="true" action-begin="GridBegin">
<e-datamanager url="/Surface/AttnConDataSource" batch-url="/Surface/AttnConBatchUpdate" adaptor="UrlAdaptor" />
<e-edit-settings allow-editing="true" allow-adding="false" allow-deleting="true" edit-mode="@(EditMode.Batch)" show-confirm-dialog="false" show-delete-confirm-dialog="true" />
<e-toolbar-settings show-toolbar="true" toolbar-items="@(new List<string>() {"add", "edit", "delete", "update","cancel" })"></e-toolbar-settings>
<e-columns>
<e-column field="Id" is-primary-key="true" visible="false" is-identity="true" type="numeric"></e-column>
</e-columns>
</ej-grid>
<div id="content">
Hello
</div>
Hello there!<br />
Org Id = @orgId
<script type="text/javascript">
function GridBegin(args) {
alert(@orgId);
}
</script>
|
<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*@ |
- As you have mentioned child grid custom button, Please confirm which means you need to render the grid inside the dialog on child grid custom button click. If not, please share more details regarding your requirement.
- Kindly confirm where you have defined the OnChildToolbarClick event. Please share the complete code example.
- If you are facing any issue/script share the screenshot of the reported issue.
<ej-dialog id="editAttn" title="Attention Contacts" show-on-init="true" content-type="ajax" content-url="@Url.Content("/Surface/Attention?orgId=1").ToString()"></ej-dialog>
</div>
if (args.itemName == "Attention") {
var childGrid = $("#" + this._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.IsPerson == false) {
if (curRow.ParentSurfaceContactId > 1) {
$("#editAttn").ejDialog({ contentUrl: "/Surface/Attention?orgId=" + curRow.ParentSurfaceContactId});
$("#editAttn").ejDialog("open");
} else {
// to do err
}
} else {
// to do err
}
} else {
// to do error msg
}
} else {
// TO DO error msg
}
}
}
{
ViewBag.OrgId = orgId;
return PartialView("_Attention", ViewBag);
}
var orgId = ViewBag.OrgId;
}
<ej-grid id="SurfAttnCon" allow-paging="true" allow-filtering="false" allow-resizing="true" allow-resize-to-fit="true" allow-sorting="false" allow-scrolling="true" allow-text-wrap="true" action-begin="GridBegin">
<e-datamanager url="/Surface/AttnConDataSource" batch-url="/Surface/AttnConBatchUpdate" adaptor="UrlAdaptor" />
<e-edit-settings allow-editing="true" allow-adding="false" allow-deleting="true" edit-mode="@(EditMode.Batch)" show-confirm-dialog="false" show-delete-confirm-dialog="true" />
<e-toolbar-settings show-toolbar="true" toolbar-items="@(new List<string>() {"add", "edit", "delete", "update","cancel" })"></e-toolbar-settings>
<e-columns>
<e-column field="Id" is-primary-key="true" visible="false" is-identity="true" type="numeric"></e-column>
</e-columns>
</ej-grid>
<ej-script-manager></ej-script-manager>
<script type="text/javascript">
var orgId = @orgId;
function GridBegin(args) {
alert("in grid");
args.model.query.addParams("OrgId", orgId);
}
</script>
- Complete Grid code example(child Grid).
- How you have get the rowDetails of the childGrid from the button click. Have you bind any unbound column in the child Grid.
- Video Demo/Screenshot to replicate the issue.
- Are you able to get correct childGrid id on the toolbarClick?. Kindly esnure it by placing a debugger in toolbar click event.
|
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> |
- Video Demo to replicate the issue.
- Replicate the issue in the above sample and revert us back.
- Have you used the above code example in your sample and after using the above code example still facing the issue, please share modified code example.
var orgId = ViewBag.OrgId;
}
var orgId = @orgId;
alert("org from normal js: " + orgId);
function GridBegin(args) {
alert("in grid");
alert(orgId);
args.model.query.addParams("OrgId", orgId);
}
</script>
var orgId = ViewBag.OrgId;
}
var orgId = @orgId;
alert("org from normal js: " + orgId);
function GridBegin(args) {
alert("in grid");
alert(orgId);
args.model.query.addParams("OrgId", orgId);
}
</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);
}
}
function GridBegin(args) {
if (args.model.query._params.length == 0) {
args.model.query.addParams("FOrgId", forgId);
} else {
if (args.model.query._params[0].key == "FOrgId") {
if (parseInt(args.model.query._params[0].value) == parseInt(forgId)) {
// value is same, do nothing
} else {
// value is different, change parameter
args.model.query._params[0].value = forgId;
}
}
}
}
- 10 Replies
- 2 Participants
-
CH Chris
- Apr 26, 2019 08:49 PM UTC
- May 9, 2019 11:41 AM UTC