|
@Html.EJS().Grid("DialogEdit").DataSource((IEnumerable<object>)ViewBag.DataSource).Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).DefaultValue("").Width("120").ValidationRules(new { required = "true"}).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("CustomerID").HeaderText("Customer Name").Width("150").DefaultValue("").ValidationRules(new { required = "true" }).Add();
}).AllowPaging().Load("load").ActionBegin("actionBegin").PageSettings(page => page.PageCount(2)).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog).Template("#dialogtemplate"); }).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render()
<script>
function load() {
var instance = document.getElementById('DialogEdit').ej2_instances[0];
instance.element.addEventListener('mousedown', function (e) {
if (e.target.classList.contains("e-rowcell")) {
if (instance.isEdit)
instance.endEdit();
var index = parseInt(e.target.getAttribute("Index"));
instance.selectRow(index);
instance.startEdit();
};
});
}
function actionBegin(args) {
debugger;
}
function actionComplete(args){
if (args.requestType === 'beginEdit') {
(args.form.elements.namedItem('CustomerID')).focus();
} else {
(args.form.elements.namedItem('OrderID')).focus();
}
}
document.addEventListener('DOMContentLoaded', function () {
setCulture();
});
</script>
<script id='dialogtemplate' type="text/x-template">
<div>
<div class="form-row">
<div class="form-group col-md-6">
<div class="e-float-input e-control-wrapper">
<input id="OrderID" name="OrderID" type="text" value="${OrderID}" ${if(isAdd)} ${else} disabled ${/if} />
<span class="e-float-line"></span>
<label class="e-float-text e-label-top" for="OrderID">Order ID</label>
</div>
</div>
<div class="form-group col-md-6">
<div class="e-float-input e-control-wrapper">
<input id="CustomerID" name="CustomerID" type="text" value="${CustomerID}" />
<span class="e-float-line"></span>
<label class="e-float-text e-label-top" for="CustomerID">Customer ID</label>
</div>
</div>
</div>
</div>
</script>
|
|
document.addEventListener('DOMContentLoaded', function () {
setCulture();
});
function setCulture() {
ej.base.setCulture('es'); // set the actual culture name here
ej.base.L10n.load({
'es': {
'grid': {
// here we you can load the translations text
"CancelButton": "Cancelar"
}
}
});
}
|
|
@Html.EJS().ChipList("chip-avatar").EnableDelete(true).Chips(chip =>
{
chip.Text("Lägg till och ta bort deltagare i kalenderbokningen i Outlook, klicka på skicka uppdatering och välj Skicka till alla deltagare".).LeadingIconCss("ms-Icon ms-Icon--Info").Enabled(true).Add();
}).Render()
|
|
@Html.EJS().ChipList("chip-avatar").EnableDelete(true).Chips(chip =>
{
chip.Text("Lägg till och ta bort deltagare i kalenderbokningen i Outlook, klicka på skicka uppdatering och välj Skicka till alla deltagare").LeadingIconCss("ms-Icon ms-Icon--Info").Enabled(true).Add();
}).Render() |
|
@Html.EJS().Grid("DialogEdit").Locale("es").DataSource((IEnumerable<object>)ViewBag.DataSource).Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).DefaultValue("").Width("120").ValidationRules(new { required = "true"}).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("CustomerID").HeaderText("Customer Name").Width("150").DefaultValue("").ValidationRules(new { required = "true" }).Add();
}).AllowPaging().Load("load").ActionBegin("actionBegin").PageSettings(page => page.PageCount(2)).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog).Template("#dialogtemplate"); }).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render()
<script>
ej.base.L10n.load({
'es': {
'grid': {
// here we you can load the translations text
"CancelButton": "Cancelar"
}
}
});
</script> |
|
Layout.cshtml
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@* Syncfusion Essential JS 2 Styles *@
@* Syncfusion Essential JS 2 Scripts *@
<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
</head>
|
|
@{
List<object> toolbarItems = new List<object>();
toolbarItems.Add("Add");
toolbarItems.Add("Edit");
toolbarItems.Add("Delete");
toolbarItems.Add("Update");
toolbarItems.Add("Cancel");
toolbarItems.Add(new { text = "CustomAdd", tooltipText = "CustomAdd", id = "Click"});
}
@Html.EJS().Grid("DialogEdit").Locale("es").DataSource((IEnumerable<object>)ViewBag.DataSource).Columns(col =>
{
. . . . . . .
}).AllowPaging().Load("load").ToolbarClick("toolbarClick").ActionBegin("actionBegin").PageSettings(page => page.PageCount(2)).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog).Template("#dialogtemplate"); }).Toolbar(toolbarItems).Render()
<script>
function toolbarClick(args) {
if (args.item.id === 'Click') {
var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
grid.addRecord(); //it helps to open the dialog when you click on that your custom toolbar item
}
}
</script>
|
|
<script>
ej.base.L10n.load({
'es': {
'grid': {
// here we you can load the translations text
"CancelButton": "Cancelar",
"Add": "CustomAdd"
}
}
});
</script>
|
|
@Html.EJS().ChipList("chip-avatar").EnableDelete(true).Chips(chip =>
{
chip.Text("Lägg till och ta bort deltagare i kalenderbokningen i Outlook, klicka på skicka uppdatering och välj Skicka till alla deltagare, Lägg till och ta bort deltagare i kalenderbokningen i Outlook, klicka på skicka uppdatering och välj Skicka till alla deltagare, Lägg till och ta bort deltagare i kalenderbokningen i Outlook, klicka på skicka uppdatering och välj Skicka till alla deltagare").LeadingIconCss("ms-Icon ms-Icon--Info").Enabled(true).Add();
}).Render()
<style>
.e-chip-list.e-chip, .e-chip-list .e-chip {
height: 100%;
}
.e-chip-list.e-chip .e-chip-text, .e-chip-list .e-chip .e-chip-text {
overflow: auto;
text-overflow: clip;
white-space: break-spaces;
margin-right:10px;
}
.e-chip-list.e-chip .e-chip-delete, .e-chip-list .e-chip .e-chip-delete {
display: contents;
}
</style> |