- Home
- Forum
- ASP.NET MVC
- Dynamic content in Dialog.
Dynamic content in Dialog.
I have a Grid with a Column template containing a link to a javascript funcyion opening up Html.EJ().Dialog defined in the cshtml file.
I want the content of the Dialog to be dynamic based on the primary key from the Grid. Is this possible and you can you provide me with a small sample ?
Regards
Jakob
I want the content of the Dialog to be dynamic based on the primary key from the Grid. Is this possible and you can you provide me with a small sample ?
Regards
Jakob
SIGN IN To post a reply.
5 Replies
FS
Farveen Sulthana Thameeztheen Basha
Syncfusion Team
March 19, 2018 12:36 PM UTC
Hi Jakob,
Thanks for contacting Syncfusion Support.
We have checked your query and by default Syncfusion Grid has the Custom Command property to display the unbound column and by using that property we can display the EJ Dialog and get the details of the corresponding row inside the Dialog.
Please refer to the documentation Link:-
Please get back to us if you need any further assistance.
Regards,
Farveen sulthana T
JH
Jakob Harper
March 19, 2018 12:44 PM UTC
Maybe I was not clear enough.
I get the primary key from the Grid, then I want to open Syncfusion Dialog with a different Dynamic dataset based on the primary key and lookup.
Basically is it possible to have proper dynamic content to the Dialog Component ?
I get the primary key from the Grid, then I want to open Syncfusion Dialog with a different Dynamic dataset based on the primary key and lookup.
Basically is it possible to have proper dynamic content to the Dialog Component ?
FS
Farveen Sulthana Thameeztheen Basha
Syncfusion Team
March 21, 2018 03:56 PM UTC
Hi Jakob,
As per your requirement, we have prepared sample by using command column. While clicking the button on command column, we have get the primarykey value of the corresponding record and send the value to the serverside. Based on primaryKey value, we have filtered the record from other table and update value while on opening the ejDialog.
Please refer to the code example:-
|
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.Columns(col =>
{
. . .
col.HeaderText("Employee Details").Commands(command =>
{
command.Type("detail")
.ButtonOptions(new Syncfusion.JavaScript.Models.ButtonProperties()
{
Text = "Details",
Width = "100px",
Click = "onClick"
}).Add();
})
.TextAlign(TextAlign.Center)
.Width(150)
.Add();
})
)
<script type="text/javascript">
function onClick(args) {
var grid = $("#FlatGrid").ejGrid("instance");
var index = this.element.closest("tr").index();
var record = grid.getCurrentViewData()[index].EmployeeID;
$.ajax({
url: "/Grid/Data",
type: "POST",
datatype: 'json',
contentType: "application/json",
data: JSON.stringify({ value: record }),
success: function (data) {
$("#commanddialog").html($("#templateData").render(data[0]))
$("#commanddialog").ejDialog("open");
},
error: function (xhr) {
alert('error');
}
});
}
</script>
<script id="templateData" type="text/x-jsrender">
<table>
<tr>
<td>
<table class="CardTable" cellpadding="3" cellspacing="2">
<tr>
<td>Order ID</td>
<td>: {{:OrderID}}</td>
</tr>
<tr>
<td>Customer ID</td>
<td>: {{:CustomerID}} </td>
</tr>s
<tr>
<td>Employee ID</td>
<td>: {{:EmployeeID}} </td>
</tr>
</table>
</td>
</tr>
</table>
</script>
Serverside:-
public ActionResult Data(int value)
{
var data = new NorthwindDataContext().OrdersViews.Where(e => e.EmployeeID == value).Take(1).ToList();
return Json(data, JsonRequestBehavior.AllowGet);
}
|
Please refer to the sample link:-
Please get back to us if you need any further assistance.
Regards,
Farveen sulthana T
JH
Jakob Harper
March 23, 2018 09:44 AM UTC
Perfect! Thank You
Regards
Jakob
Regards
Jakob
FS
Farveen Sulthana Thameeztheen Basha
Syncfusion Team
March 26, 2018 12:31 PM UTC
Hi Jakob,
Thanks for your update. Please get back to us if you need any further assistance.
Regards,
Farveen sulthana T
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
-
JH Jakob Harper
- Mar 16, 2018 12:50 PM UTC
- Mar 26, 2018 12:31 PM UTC