Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
148205 | Oct 10,2019 12:56 AM UTC | Oct 29,2019 05:27 AM UTC | ASP.NET MVC - EJ 2 | 15 |
![]() |
Tags: Grid |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@* Syncfusion Essential JS 2 Styles *@
<link rel="stylesheet" rel='nofollow' href="https://cdn.syncfusion.com/ej2/material.css" />
@* Syncfusion Essential JS 2 Scripts *@
<script src="~/Scripts/ej2/ej2.js"></script>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery") // Move the Jquery and bootstrap scripts in your header tag
@Scripts.Render("~/bundles/bootstrap")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - My ASP.NET Application</p>
</footer>
</div>
@Html.EJS().ScriptManager() //The ScriptManager used to place our control initialization script in the page.
You can place your code after the script manager.
<script id="_agile_min_js" async type="text/javascript" src="https://floodlightsoft.agilecrm.com/stats/min/agile-min.js"></script>
<script type="text/javascript">
var agile_api = agile_api || {}; agile_api.on_after_load = function () {
_agile.set_account('j4vbincjpg460bkkkekbq43hlj', 'floodlightsoft', false);
_agile.track_page_view()
_agile_execute_web_rules();
};
</script>
</body>
</html>
|
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").Add();
col.Field("Freight").HeaderText("Freight").Format("C2").Add();
}).Load("load").Render()
<script>
function load(args) {
var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
grid.renderModule.updateColumnType = function (record) {
var columns = this.parent.getColumns();
var value;
var cFormat = 'customFormat';
var equalTo = 'equalTo';
var data = record && record.items ? record.items[0] : record;
var fmtr = this.locator.getService('valueFormatter');
for (var i = 0, len = columns.length; i < len; i++) {
value = ej.base.getValue(columns[i].field || '', data);
if (!ej.base.isNullOrUndefined(columns[i][cFormat])) {
columns[i].format = columns[i][cFormat];
}
if (!ej.base.isNullOrUndefined(columns[i].validationRules) && !ej.base.isNullOrUndefined(columns[i].validationRules[equalTo])) {
columns[i].validationRules[equalTo][0] = this.parent.element.id + columns[i].validationRules[equalTo][0];
}
if (columns[i].isForeignColumn() && columns[i].columnData) {
value = ej.base.getValue(columns[i].foreignKeyValue || '', columns[i].columnData[0]);
}
if (!ej.base.isNullOrUndefined(value)) {
this.isColTypeDef = true;
if (!columns[i].type) {
columns[i].type = value.getDay ? (value.getHours() > 0 || value.getMinutes() > 0 ||
value.getSeconds() > 0 || value.getMilliseconds() > 0 ? 'datetime' : 'date') : typeof (value);
}
}
else {
columns[i].type = columns[i].type || null;
}
var valueFormatter = new ej.grids.ValueFormatter();
if ((columns[i].format && typeof columns[i].format === 'object') && (columns[i].format.skeleton || columns[i].format.format)) // your reffered third party script was override this condition. So we override this method and prevent this condition . {
columns[i].setFormatter(valueFormatter.getFormatFunction(columns[i].format));
columns[i].setParser(valueFormatter.getParserFunction(columns[i].format));
}
if (typeof (columns[i].format) === 'string') {
ej.grids.setFormatter(this.locator, columns[i]);
}
else if (!columns[i].format && columns[i].type === 'number') {
columns[i].setParser(fmtr.getParserFunction({ format: 'n2' }));
}
}
}
}
</script> |
function load(args) {
ej.grids.ValueFormatter.prototype.getFormatFunction = function (format) {
if (format.type) {
return ej.base.Internationalization.prototype.getDateFormat(format);
}
else {
if (typeof format === "string") {
format = { format: format }; // your reffered third party script was conflict with our methods. So we override this method and convert the format type to object.
return ej.base.Internationalization.prototype.getNumberFormat(format);
}
}
}
ej.grids.ValueFormatter.prototype.getParserFunction = function (format) {
if (format.type) {
return ej.base.Internationalization.prototype.getDateParser(format);
}
else {
if (typeof format === "string") {
format = { format: format };
return ej.base.Internationalization.prototype.getNumberParser(format);
}
}
}
} |
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.