or
@(Html.Kendo().Grid<
StorageClasses
>()
.Name("StorageClassesGrid")
.ToolBar(toolbar => toolbar.Template("<
button
id
=
'btnAddSC'
class
=
'k-button'
><
span
class
=
'k-icon k-add'
></
span
></
button
>"))
.Columns(columns =>
{
columns.Command(command =>
{
command.Destroy().Text(" ").HtmlAttributes(new { style = "width:14px;min-width:27px" });
}).Width("40px;");
columns.Bound(p => p.Name);
columns.Bound(p => p.Remark);
})
.Pageable(pager => pager.Refresh(true))
.Sortable()
.Scrollable(s => s.Height("auto"))
.Filterable()
.Resizable(r => r.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Model(model => model.Id(m => m.ID))
.Read(read => read.Action("GetStorageClassesByLocation", "Locations", new { LocationID = Model.ID }))
.Destroy(destroy => destroy.Action("StorageClass_Delete", "Locations", new { LocationID = Model.ID }))
.Events(e => e.Error("onGridError"))
)
.Events(e => e.Remove("onGridRowRemove").DataBound("resizeTabs"))
)
[HttpPost]
public ActionResult StorageClass_Delete([DataSourceRequest] DataSourceRequest request, long? LocationID, StorageClasses StorageClass)
{
Exception exception;
if (StorageClass != null && LocationID != null)
{
try
{
if (ModelState.IsValid)
{
// delete entity in database
var result = _db.StorageClass_Delete(
LocationID.HasValue ? LocationID.Value : 0,
StorageClass.ID,
ClientName,
"WEB",
UserName,
out exception);
if (exception != null)
{
AddException(exception);
}
// check database action result
if (result != null && result.ErrorID == 0)
{
// database action successful
return Json(new[] { StorageClass }.ToDataSourceResult(request, ModelState));
}
else
{
ModelState.AddModelError("StorageClass_Delete", result.ErrorMessage);
return Json(new[] { StorageClass }.ToDataSourceResult(request, ModelState));
}
}
}
catch (Exception ex)
{
AddException(ex);
ModelState.AddModelError("StorageClass_Delete", ex.Message);
return Json(new[] { StorageClass }.ToDataSourceResult(request, ModelState));
}
}
ModelState.AddModelError("StorageClass_Delete", "Parameter Fehler.");
return Json(new[] { StorageClass }.ToDataSourceResult(request, ModelState));
}
function onGridError(e) {
var txt = "";
$.each(e.errors, function (propertyName) {
txt = txt +this.errors + " ";
});
$("#lblStatus").text(txt);
$("#lblStatus").css('color', 'red', 'font-weight ', 'bold');
}
@(Html.Kendo().ComboBox()<
br
>
.Name("IDTYPE")<
br
>
//.AutoBind(false)<
br
>
//.Events(e => e<
br
>
// .Change("combobox_select"))<
br
>
.DataTextField("DESCRIPTION").HtmlAttributes(new { style = "width:220px", required = "required" })<
br
>
.DataValueField("REFERENCEID")<
br
>
// .Value(Model.IDTYPEGUID.ToString()) // Initial value<
br
>
// .BindTo(Model.IDTYPE) <
br
>
//.AutoBind(true) <
br
>
.Placeholder("SELECT")<
br
>
<
br
>
.DataSource(source =><
br
>
{<
br
>
source.Read(read =><
br
>
{<
br
>
<
br
>
read.Action("GetDefinitionDetails", "Definition", new { definitionCode = "IDTYPE", addEmptyRow = false })<
br
>
// .Data("onAdditionalData")<
br
>
;<
br
>
<
br
>
})<
br
>
.ServerFiltering(true);<
br
>
<
br
>
}))
@(Html.Kendo().TreeView()
.Name("MyTreeView")
.BindTo(Model, mappings => mappings.For<
TreeViewNode
>(binding => binding
.ItemDataBound((item, node) =>
{
item.Text = node.Name;
item.Id = node.Value.ToString();
item.Expanded = ViewData[ViewBag.ExpandedCookie] != null &&
((string[])ViewData[ViewBag.ExpandedCookie]).Contains(item.Id);
//item.HtmlAttributes["data-selectable"] = node.Selectable;
if (node.AddOnly)
item.HtmlAttributes["data-addOnly"] = true;
else
item.HtmlAttributes["data-addOnly"] = false;
if (!node.Selectable)
{
item.HtmlAttributes["style"] = "color: #888";
}
else
item.HtmlAttributes["style"] = "color: black";
})
.Children(parent => parent.Childs))).HtmlAttributes(new { @class = "k-group" }).Events(e => e
.Select("onSelect")
.Expand("updateTreeViewState")
.Collapse("updateTreeViewState")
.DragStart("onNodeDragStart")
.DataBound("onTreeDataBound")
.Drop("onNodeDrop")).DragAndDrop(true)
)
function onTreeDataBound(e) {
alert("databound");
}
// select event as an example (this works)
function onSelect(e) {
var dataItem = this.dataItem(e.node);
$("#ID").val(dataItem.id);
if ($(e.item).attr("data-selectable") == "0" || dataItem.id == "0")
e.preventDefault();
else
// request server for partial view for details and refresh right pane of splitter
getSplitter("#outerSplitter").ajaxRequest("#right-pane", "/" + getArea() + "/" + getController() + "/Details", { id: dataItem.id });
// update statusbar to default
$("#lblStatus").text("Ready");
$("#lblStatus").css('color', 'black', 'font-weight ', 'normal')
//}
}
.TemplateName("EditPerson"))
@model IEnumerable<HCS.Model.FinancialInstitution>
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.ID).Visible(false);
columns.Bound(p => p.MainRT).Title("RT").Groupable(false);
columns.Bound(p => p.LegalName).Title("FI Name");
})
.Sortable()
.Scrollable()
.Filterable()
.Selectable()
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false))
)
public ActionResult Grid()
{
context.Configuration.ProxyCreationEnabled = false;
var model = context.FinancialInstitutions.ToList();
return View();
}
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CustomerService.Models;
using System.Web.Security;
using System.Security.Principal;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
namespace CustomerService.Controllers
{
[Authorize]
public class CaseController : Controller
{
private ERPEntities db = new ERPEntities();
public ActionResult Cases_Read([DataSourceRequest]DataSourceRequest request)
{
IQueryable<
CaseHeader
> cases = db.CaseHeaders;
DataSourceResult result = cases.ToDataSourceResult(request);
return Json(result, JsonRequestBehavior.AllowGet);
}
public ActionResult Cases_Create([DataSourceRequest]DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<
CaseHeader
> cases)
{
// Will keep the inserted entitites here. Used to return the result later.
var entities = new List<
CaseHeader
>();
if (ModelState.IsValid)
{
foreach (var x in cases)
{
// Create a new Product entity and set its properties from the posted ProductViewModel
var entity = new CaseHeader
{
CaseHeaderId = x.CaseHeaderId,
Creator = x.Creator,
CreatedDate = x.CreatedDate,
CaseLead = x.CaseLead,
CaseSubType1 = x.CaseSubType1,
CaseSubType2 = x.CaseSubType2,
CaseStatus = x.CaseStatus,
CaseTitle = x.CaseTitle,
CaseDescription = x.CaseDescription,
CaseContact = x.CaseContact
};
// Add the entity
db.CaseHeaders.Add(entity);
// Store the entity for later use
entities.Add(entity);
}
// Insert the entities in the database
db.SaveChanges();
}
// Return the inserted entities. The grid needs the generated ProductID. Also return any validation errors.
return Json(entities.ToDataSourceResult(request, ModelState, x => new CaseHeader
{
CaseHeaderId = x.CaseHeaderId,
Creator = x.Creator,
CreatedDate = x.CreatedDate,
CaseLead = x.CaseLead,
CaseSubType1 = x.CaseSubType1,
CaseSubType2 = x.CaseSubType2,
CaseStatus = x.CaseStatus,
CaseTitle = x.CaseTitle,
CaseDescription = x.CaseDescription,
CaseContact = x.CaseContact
}));
}
public ActionResult Cases_Update([DataSourceRequest]DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<
CaseHeader
> cases)
{
// Will keep the updated entitites here. Used to return the result later.
var entities = new List<
CaseHeader
>();
if (ModelState.IsValid)
{
foreach (var x in cases)
{
// Create a new Product entity and set its properties from the posted ProductViewModel
var entity = new CaseHeader
{
CaseHeaderId = x.CaseHeaderId,
Creator = x.Creator,
CreatedDate = x.CreatedDate,
CaseLead = x.CaseLead,
CaseSubType1 = x.CaseSubType1,
CaseSubType2 = x.CaseSubType2,
CaseStatus = x.CaseStatus,
CaseTitle = x.CaseTitle,
CaseDescription = x.CaseDescription,
CaseContact = x.CaseContact
};
// Store the entity for later use
entities.Add(entity);
// Attach the entity
db.CaseHeaders.Attach(entity);
// Change its state to Modified so Entity Framework can update the existing product instead of creating a new one
db.Entry(entity).State = EntityState.Modified;
// Or use ObjectStateManager if using a previous version of Entity Framework
// northwind.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
}
// Update the entities in the database
db.SaveChanges();
}
// Return the updated entities. Also return any validation errors.
return Json(entities.ToDataSourceResult(request, ModelState, x => new CaseHeader
{
CaseHeaderId = x.CaseHeaderId,
Creator = x.Creator,
CreatedDate = x.CreatedDate,
CaseLead = x.CaseLead,
CaseSubType1 = x.CaseSubType1,
CaseSubType2 = x.CaseSubType2,
CaseStatus = x.CaseStatus,
CaseTitle = x.CaseTitle,
CaseDescription = x.CaseDescription,
CaseContact = x.CaseContact
}));
}
public ActionResult Cases_Destroy([DataSourceRequest]DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<
CaseHeader
> cases)
{
// Will keep the destroyed entitites here. Used to return the result later.
var entities = new List<
CaseHeader
>();
if (ModelState.IsValid)
{
foreach (var x in cases)
{
// Create a new Product entity and set its properties from the posted ProductViewModel
var entity = new CaseHeader
{
CaseHeaderId = x.CaseHeaderId,
Creator = x.Creator,
CreatedDate = x.CreatedDate,
CaseLead = x.CaseLead,
CaseSubType1 = x.CaseSubType1,
CaseSubType2 = x.CaseSubType2,
CaseStatus = x.CaseStatus,
CaseTitle = x.CaseTitle,
CaseDescription = x.CaseDescription,
CaseContact = x.CaseContact
};
// Store the entity for later use
entities.Add(entity);
// Attach the entity
db.CaseHeaders.Attach(entity);
// Delete the entity
db.CaseHeaders.Remove(entity);
// Or use DeleteObject if using a previous versoin of Entity Framework
// northwind.Products.DeleteObject(entity);
}
// Delete the entity in the database
db.SaveChanges();
}
// Return the destroyed entities. Also return any validation errors.
return Json(entities.ToDataSourceResult(request, ModelState, x => new CaseHeader
{
CaseHeaderId = x.CaseHeaderId,
Creator = x.Creator,
CreatedDate = x.CreatedDate,
CaseLead = x.CaseLead,
CaseSubType1 = x.CaseSubType1,
CaseSubType2 = x.CaseSubType2,
CaseStatus = x.CaseStatus,
CaseTitle = x.CaseTitle,
CaseDescription = x.CaseDescription,
CaseContact = x.CaseContact
}));
}
}
}
@model IEnumerable<
CustomerService.Models.CaseHeader
>
@{
ViewBag.Title = "Index";
}
<
h2
>Your Cases</
h2
>
@(Html.Kendo().Grid<
CustomerService.Models.CaseHeader
>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(x => x.CaseHeaderId);
columns.Bound(x => x.Creator);
columns.Bound(x => x.CreatedDate);
columns.Bound(x => x.CaseLead);
columns.Bound(x => x.CaseType);
columns.Bound(x => x.CaseSubType1);
columns.Bound(x => x.CaseSubType2);
columns.Bound(x => x.CaseStatus);
columns.Bound(x => x.CaseTitle);
columns.Bound(x => x.CaseDescription);
columns.Bound(x => x.CaseContact);
columns.Command(commands =>
{
commands.Destroy(); // The "destroy" command removes data items
}).Title("Commands").Width(200);
})
.ToolBar(toolbar =>
{
toolbar.Create(); // The "create" command adds new data items
toolbar.Save(); // The "save" command saves the changed data items
})
.Editable(editable => editable.Mode(GridEditMode.InCell)) // Use in-cell editing mode
.DataSource(dataSource =>
dataSource.Ajax()
.Batch(true) // Enable batch updates
.Model(model =>
{
model.Id(x => x.CaseHeaderId); // Specify the property which is the unique identifier of the model
model.Field(x => x.CaseHeaderId).Editable(false); // Make the CaseHeaderId property not editable
model.Field(x => x.CreatedDate).Editable(false);
})
.Create(create => create.Action("Cases_Create", "Case")) // Action method invoked when the user saves a new data item
.Read(read => read.Action("Cases_Read", "Case")) // Action method invoked when the grid needs data
.Update(update => update.Action("Cases_Update", "Case")) // Action method invoked when the user saves an updated data item
.Destroy(destroy => destroy.Action("Cases_Destroy", "Case")) // Action method invoked when the user removes a data item
)
.Pageable()
)
using System;
using System.Collections.Generic;
namespace CustomerService.Models
{
public partial class CaseHeader
{
public CaseHeader()
{
this.Notes = new HashSet<
Note
>();
}
public System.Guid CaseHeaderId { get; set; }
public System.Guid UserId { get; set; }
public string Creator { get; set; }
public Nullable<
System.DateTime
> CreatedDate { get; set; }
public string CaseLead { get; set; }
public string CaseType { get; set; }
public string CaseSubType1 { get; set; }
public string CaseSubType2 { get; set; }
public string CaseStatus { get; set; }
public string CaseTitle { get; set; }
public string CaseDescription { get; set; }
public string CaseContact { get; set; }
public virtual aspnet_Users aspnet_Users { get; set; }
public virtual ICollection<
Note
> Notes { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
namespace CustomerService.Models
{
[MetadataType(typeof(CaseHeaderMetaData))]
public partial class CaseHeader
{
}
public class CaseHeaderMetaData
{
public System.Guid CaseHeaderId { get; set; }
public System.Guid UserId { get; set; }
[MaxLength(50, ErrorMessage = "Too Long!")]
public string Creator { get; set; }
public Nullable<
System.DateTime
> CreatedDate { get; set; }
public string CaseLead { get; set; }
public string CaseType { get; set; }
public string CaseSubType1 { get; set; }
public string CaseSubType2 { get; set; }
public string CaseStatus { get; set; }
public string CaseTitle { get; set; }
public string CaseDescription { get; set; }
public string CaseContact { get; set; }
public virtual aspnet_Users aspnet_Users { get; set; }
public virtual ICollection<
Note
> Notes { get; set; }
}
[MetadataType(typeof(UserProfileMetaData))]
public partial class UserProfile
{
}
public class UserProfileMetaData
{
public System.Guid UserId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
[Display(Name = "Request Company")]
public string Company { get; set; }
public string CompanyNumber { get; set; }
public virtual aspnet_Users aspnet_Users { get; set; }
}
}