<div id="divGrid" class="row"> <div class="col-md-12"> @Html.EJS().Grid("Index").DataSource((IEnumerable<object>)ViewBag.dataSource).Load("load").AllowResizing().AllowPaging().PageSettings(page => { page.PageSize(100); }).AllowSorting().AllowFiltering().FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.Excel); }).AllowGrouping().Columns(col => { col.Field("MensagemId").IsPrimaryKey(true).IsIdentity(true).Visible(false).Add(); col.Field("type").HeaderText("Tipo").HeaderTextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Width(30).Add(); col.Field("ConteudoASCII").HeaderText("Mensagem").HeaderTextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add(); col.Field("DataRegistro").HeaderText("Data Registro").HeaderTextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Width(60).Add(); col.Field("DataEnvio").HeaderText("Data Envio").HeaderTextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Width(60).Add(); }).SearchSettings(search => { search.Operator("contains").IgnoreCase(true).IgnoreAccent(true); }).Toolbar(new List<string>() { "Search" }).Locale("en-US").RecordDoubleClick("LoadRegistro").Render() </div> </div> @section Scripts { <script type="text/javascript" charset="UTF-8"> //ej2.parse = false; function load(args) { this.columns[3].format = { type: 'date', format: 'dd/MM/yyyy HH:mm' }; this.columns[4].format = { type: 'date', format: 'dd/MM/yyyy HH:mm' }; } //REFRESH DEAFULT GRID function UpdateGrid() { var grid = document.getElementById("Index").ej2_instances[0]; // Grid instance var ajax = new ej.base.Ajax('/NotificacaoMensagem/DataSource', 'GET'); ajax.send(); ajax.onSuccess = function (data) { grid.dataSource = JSON.parse(data).result; LoadingOff(); alert("1"); }; }
public partial class VNotificacao_GridMensagem { public int MensagemId { get; set; } public System.Guid MensagemUnique { get; set; } public string ConteudoASCII { get; set; } public string ConteudoBase64 { get; set; } public string fname { get; set; } public string caption { get; set; } public int type { get; set; } public System.DateTime DataRegistro { get; set; } public bool Pergunta { get; set; } public Nullable<System.DateTime> LimiteResposta { get; set; } public Nullable<System.DateTime> DataEnvio { get; set; } public Nullable<System.DateTime> DataExclusao { get; set; } }
public JsonResult DataSource() var Dados = cactusDBEntities.VNotificacao_GridMensagem.ToList(); int count = Dados.Cast<VNotificacao_GridMensagem> ().Count(); return Json(new { result = Dados, count = count }, JsonRequestBehavior.AllowGet); }
@Html.EJS().Grid("Index").Load("load").Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width("120").Add();
col.Field("OrderDate").HeaderText("Data Registro").HeaderTextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Center).Width(60).Add();
}).AllowPaging().ActionFailure("fail").Render()
<script>
function load(args) {
this.columns[1].format = { type: 'date', format: 'dd/MM/yyyy HH:mm' };
var grid = document.getElementById("Index").ej2_instances[0]; // Grid instance
var result = JSON.parse(data).result; // data is a string contains result and count
grid.dataSource = ej.data.DataUtil.parse.parseJson(result);
}
</script> |