Open farzinmonsef opened 6 years ago
$(document).ready(function () { $("#grid").kendoTooltip({ //filter: "td[1n]||td[2n]", //this filter selects the second column's cells filter: "td:nth-child(2):not(:has(input))", //this filter selects the second column's cells position: "right", Template: " My-Guide: #= ShipName#>", content: function (e) { var dataItem = $("#grid").data("kendoGrid").dataItem(e.target.closest("tr")); var content = 'My Guide: '+dataItem.ShipName; return content; } }).data("kendoTooltip"); });
https://www.codeproject.com/Tips/434175/Adding-On-Row-Click-to-the-KendoUI-Grid
var grid = $("#kGrid").kendoGrid({ ... change: function (arg) { var selected = $.map(this.select(), function (item) { return $(item).find('td').first().text(); }); alert(selected); }, });
https://www.telerik.com/forums/dynamic-default-values ............................................................................................................................................................. .ToolBar(toolbar => { toolbar.Create().Text("Add row"); }) ... .Model(model => { model.Id(n => n.ID); model.Field(c => c.count).DefaultValue(<this value needs to be max value + 1>); model.Field(c => c.count).Editable(false); })
............................................................................................................................................................. function onEdit(e) { e.container.find("[name=fieldName]").hide(); } ............................................................................................................................................................. function onEdit(e) { //execute your custom logic to get the max value var maxValue = 5; //check if record is new if (e.model.isNew()) { //set the required field value e.model.set("OrderCount", maxValue + 1); } }
https://docs.telerik.com/aspnet-mvc/helpers/grid/how-to/editing/custom-popup-editor https://github.com/telerik/ui-for-aspnet-mvc-examples
@(Html.Kendo().Grid
.Pageable()
.Sortable()
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("Person"))
)
using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Net; using System.Web; using System.Web.Mvc; using Kendo.Mvc.Extensions; using Kendo.Mvc.UI; using DynamicDataValues.Models;
namespace DynamicDataValues.Controllers { public class PersonController : Controller { private GridEntities db = new GridEntities();
public ActionResult Index()
{
return View();
}
public ActionResult People_Read([DataSourceRequest]DataSourceRequest request)
{
IQueryable<Person> people = db.People;
DataSourceResult result = people.ToDataSourceResult(request, person => new {
id = person.id,
name = person.name,
salary = person.salary
});
return Json(result);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult People_Create([DataSourceRequest]DataSourceRequest request, Person person)
{
if (ModelState.IsValid)
{
var entity = new Person
{
name = person.name,
salary = person.salary
};
db.People.Add(entity);
db.SaveChanges();
person.id = entity.id;
}
return Json(new[] { person }.ToDataSourceResult(request, ModelState));
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult People_Update([DataSourceRequest]DataSourceRequest request, Person person)
{
if (ModelState.IsValid)
{
var entity = new Person
{
id = person.id,
name = person.name,
salary = person.salary
};
db.People.Attach(entity);
db.Entry(entity).State = EntityState.Modified;
db.SaveChanges();
}
return Json(new[] { person }.ToDataSourceResult(request, ModelState));
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult People_Destroy([DataSourceRequest]DataSourceRequest request, Person person)
{
if (ModelState.IsValid)
{
var entity = new Person
{
id = person.id,
name = person.name,
salary = person.salary
};
db.People.Attach(entity);
db.People.Remove(entity);
db.SaveChanges();
}
return Json(new[] { person }.ToDataSourceResult(request, ModelState));
}
[HttpPost]
public ActionResult Excel_Export_Save(string contentType, string base64, string fileName)
{
var fileContents = Convert.FromBase64String(base64);
return File(fileContents, contentType, fileName);
}
[HttpPost]
public ActionResult Pdf_Export_Save(string contentType, string base64, string fileName)
{
var fileContents = Convert.FromBase64String(base64);
return File(fileContents, contentType, fileName);
}
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}
[HttpPost]
public void SetDate()
{
Session["TestValue"] = DateTime.Now.ToString("HHmm", System.Globalization.CultureInfo.GetCultureInfo("en-US"));
}
[HttpPost]
public ActionResult getSession()
{
return Json((Session["TestValue"] ?? ""), JsonRequestBehavior.AllowGet);
//return new JsonResult ({new data: Session["TestValue"] ?? "" });
}
}
}
@{ Layout = "~/Views/Shared/_Layout.cshtml"; }
@@Html.ActionLink("SetDate", "SetDate", "Person", null, null)@
@type="submit" onclick="callClick" @
@(Html.Kendo().Grid
@model DynamicDataValues.Models.Person
@{ ViewBag.Title = "Edit"; }
@using (Html.BeginForm()) { @Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Student</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.id)
<div class="form-group">
@Html.LabelFor(model => model.name, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.name, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.salary, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.salary, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.salary, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
@@section Scripts { @Scripts.Render("~/bundles/jqueryval") }@
https://www.codeproject.com/Articles/1063846/Step-By-Step-Implementation-of-MultiSelectList-In
https://stackoverflow.com/questions/21826280/selectedvalues-not-working-in-multiselectlist-mvc
https://visualstudiomagazine.com/articles/2017/06/09/tip-aspnet-mvc-multiselect-dropdown.aspx
https://www.dropbox.com/s/i0bhymspkb0ofhw/Sample-MultiSelect.zip?dl=0
Kendo Grid and else