@(Html.EJ().Grid<object>("FlatGrid")
..
.Columns(col =>
{
..
col.Field("CustomerID").HeaderText("Customer ID").EditTemplate(a => { a.Create("create").Read("read").Write("write"); }).TextAlign(TextAlign.Right).Width(90.Add();
..
.ClientSideEvents(events=>events.CellEdit("onCellEdit").TemplateRefresh("TemplateRefresh"))
)
<script type="text/javascript">
function create() {
return $("<div class='e-field'>");
}
function write(args) {
var proxy = args;
args.element.ejUploadbox({
saveUrl: "/Home/saveFiles",
extensionsAllow: ".zip",
complete: function (args) {
proxy.element.val(args.responseText);
},
uploadName: "FlatGridEmployeeID",
});
proxy.element.val(proxy.rowdata.CustomerID);
}
function read(args) {
return args.val();
}
</script>
Homeontroller.cs
public ActionResult saveFiles()
{
if (HttpContext.Request.Files.AllKeys.Any())
{
var httpPostedFile = HttpContext.Request.Files["FlatGridEmployeeID"];
if (httpPostedFile != null)
{
if (httpPostedFile.FileName.Contains("\\"))
{
string[] pathArr = httpPostedFile.FileName.Split('\\');
fileName = pathArr.Last();
}
else
fileName = httpPostedFile.FileName;
destination = Path.Combine(HttpContext.Server.MapPath("~/App_Data"), fileName);
// To avoid unwanted storage in server we have commentted the below line
httpPostedFile.SaveAs(destination);
}
}
return Content(destination);
} |
<script type="text/javascript">
var serverTimeZoneDiff = +4.0
var clientSideTimeZoneDiff = new Date().getTimezoneOffset() / 60; // get client time zone differents and convert it to hours;
ej.serverTimeZoneOffset = serverTimeZoneDiff + clientSideTimeZoneDiff;
</script> |
<input type="button" value="DataPicker Enable" onclick="DateEnable()" /><br /><br />
<input type="button" value="DataPicker Disbale" onclick="DateDisable()" /><br /><br />
<input type="button" value="DropDown Enable" onclick="DropDownEnable()" /><br /><br />
<input type="button" value="DropDown Disbale" onclick="DropDownDisable()" /><br /><br />
@Html.EJ().DatePicker("DatePick").EnablePersistence(true).Value(ViewBag.datevalue)
@Html.EJ().DropDownList("selectCar").TargetID("carsList").Width("100%").WatermarkText("Select a Car")
<script type="text/javascript">
function DateEnable() {
var dateObj = $("#DatePick").data("ejDatePicker");
dateObj.enable(); // enables the datepicker
}
function DateDisable() {
var dateObj = $("#DatePick").data("ejDatePicker");
dateObj.disable(); // enables the datepicker
}
function DropDownEnable() {
var DropDownListObj = $("#selectCar").data("ejDropDownList");
DropDownListObj.enable(); //Enables the DropDownList text.
}
function DropDownDisable() {
var DropDownListObj = $("#selectCar").data("ejDropDownList");
DropDownListObj.disable(); //Hides the DropDownList text.
}
</script> |
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource(ds => ds.URL("/Grid/BatchData").BatchURL("/Grid/BatchUpdate").Adaptor(AdaptorType.UrlAdaptor))
.AllowPaging() /*Paging Enabled*/
. . . .
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
//Assign DatePicker for String Column
col.Field("CustomerID").EditType(EditingType.Datepicker).HeaderText("Customer ID").Width(80).Add();
})
)
public ActionResult BatchUpdate(string key, List<OrdersView> changed, List<OrdersView> added, List<OrdersView> deleted)
{
var Data = new NorthwindDataContext().OrdersViews;
if (added != null)
{
for (var add = 0; add < added.Count(); add++)
{
/* Parse the string to Date
* It will change to its original value
* Since CustomerID is the string column
* We cannot assign Parsed date back to original value
*/
DateTime dat = DateTime.Parse(added[add].CustomerID);
Data.InsertOnSubmit(added[add]);
}
}
if (changed != null)
{
. . . .
}
return Json(Data.ToList(), JsonRequestBehavior.AllowGet);
} |
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource(ds => ds.URL("/Grid/BatchData").BatchURL("/Grid/BatchUpdate").Adaptor(AdaptorType.UrlAdaptor))
. . ..
) |
@(Html.EJ().Grid<object>("FlatGrid")
.Columns(col =>
{
col.HeaderText("Add Values").Commands(command =>
{
command.Type("detail")
.ButtonOptions(new Syncfusion.JavaScript.Models.ButtonProperties()
{
Text = "Add",
Width = "100px",
Click = "onClick"
}).Add();
})
.TextAlign(TextAlign.Left)
.Width(150)
.Add();
. . . .
})
.ClientSideEvents(eve=>eve.BatchAdd("batchAdd"))
)
function batchAdd(args){
$(args.row).find(".e-detailbutton").ejButton({
text: "ADD", height: "28px", width: "100px",
click: "onClick",
enable: false, htmlAttributes: { enabled: "enabled" }
});
} |
function onClick(args) {
var obj = $("#FlatGrid").ejGrid("instance");
var inx = obj.getIndexByRow(this.element.parents("tr"));
var rowdata = obj.getCurrentViewData()[obj.getIndexByRow(this.element.parents("tr"))];
} |