Have a dependent grid column that is a dropdown based on a parent column.
The dependent field is filtered on its accepted values on the popup editor based on the selection on the parent column.
But on the grid, I am just showing the current value, like so:
columns.Bound(o => o.CountyId).ClientTemplate("#if(CountyId.Value!=null){##=CountyId.Value##}#").Sortable(false).Groupable(false).Filterable(false);
[UIHint("CountyEditor")]
[Display(Name = "County")]
public ChildValueViewModelNullable CountyId { get; set; }
Would like to enable filtering "AND" sorting on this column. Would be happy with just a text field where users can enter in the search term for the filtering.
Do you have code/sample for this?
Thnks.
Hi
I'm using Telerik_UI_for_ASP.NET_AJAX_2019_1_215_Dev
This is a licensed version, that my company has purchased.
Why do I get the 'Trial Message' on the controls?
thx
When I filter out data on tree list I am running into 2 issues:
1) the number of pages doesn't reflect the number of items shown in the list
2) the child items will remain in the list even if filtered out
My expectation is that when filter is applied, it would only show Carla and have 1 page on paging bar. Strangely if I execute $("#AttendeeGrid").data("kendoTreeList").dataSource.read(); again after filtering through browser console the children are then removed.
View
<
script
type
=
"text/javascript"
>
var filter = false;
function toggleFilter() {
filter = !filter;
$("#AttendeeGrid").data("kendoTreeList").dataSource.read();
$("#AttendeeGrid").data("kendoTreeList").dataSource.page(1);
}
function attendeeParams() {
return {
myFilter: filter
}
}
</
script
>
@(Html.Kendo().TreeList<
AttendeeItem
>()
.Name("AttendeeGrid")
.Columns(columns =>
{
columns.Add().Field(x => x.firstName).Title("First");
})
.Sortable()
.DataSource(dataSource => dataSource
.ServerOperation(false)
.Read(read => read.Action("attendee_Read", "Home").Data("attendeeParams"))
.Model(m => {
m.Id(x => x.primaryRegistrationId);
m.ParentId(x => x.parentRegistrationId);
m.Expanded(true);
})
)
.Pageable(p => p.PageSize(5))
.Scrollable(false)
)
<
button
onclick
=
"toggleFilter()"
>Toggle filter</
button
>
Controller
...
public IActionResult attendee_Read([DataSourceRequest] DataSourceRequest request, GetAttendeesParams getAttendeesParams)
{
AttendeeItem[] items;
if (getAttendeesParams.myFilter)
{
items = new[]
{
new AttendeeItem
{
primaryRegistrationId = 1,
firstName = "Carla",
parentRegistrationId = null
}
};
}
else
{
items = new[]
{
new AttendeeItem
{
primaryRegistrationId = 1,
firstName = "Carla",
parentRegistrationId = null
},
new AttendeeItem
{
primaryRegistrationId = 2,
firstName = "Roger",
parentRegistrationId = null
},
new AttendeeItem
{
primaryRegistrationId = 3,
firstName = "Katy",
parentRegistrationId = null
},
new AttendeeItem
{
primaryRegistrationId = 4,
firstName = "Bob",
parentRegistrationId = null
},
new AttendeeItem
{
primaryRegistrationId = 5,
firstName = "Avni",
parentRegistrationId = 1
},
new AttendeeItem
{
primaryRegistrationId = 6,
firstName = "George",
parentRegistrationId = null
},
};
}
return Json(items.ToTreeDataSourceResult(request));
}
}
public class AttendeeItem
{
public string firstName { get; set; }
public int primaryRegistrationId { get; set; }
public int? parentRegistrationId { get; set; }
}
public class GetAttendeesParams
{
public bool myFilter { get; set; }
}
Hi All
I'm using the panelbar in an asp.net core project, like so:
@(Html.Kendo().PanelBar().Name("s").Items(p =>
{
p.Add().Text("Manufacturers").Content(@<text>
However, I have noticed that nothing appears on the page in the browser. Please advise?
Hello Folks,
I always get the "there was an error running the selected code generator: "Package restore failed. Rolling back package changes for 'projectname'"-Error when i try to add new Razor Pages. What's the Problem? I'm using VS2019 and the ASP.NET Telerik Trial
I made two identical grids.
One using the Html helper and one using the Tag helper.
Both have inline editing enabled.
However the editor templates don't seem to correspond or not even be present in some cases.
I've attached a screenshot.
How do I just make it work in both cases?
I am trying to achieve inline insertion in a grid with client side code. I am using tag helper and generating toolbar with custom button and binding click event with javaScript function. And through this function I need to achieve functionality of "Create" button under grid's toolbar option.
To elaborate the things, there are two toolbar one is "kindo-toolbar" and another is "toolbar" under "kendo-grid". Toolbar under kendo-grid is having "Add new record" button and on click on this button generates new blank row in grid to add new record. This same functionality I need to achieve through "Kendo-toolbar" item button, where I can bind a click event with a javascript function. So is there a way to implement inline row adding with toolbar item with javascript or any other approach?
<
div
class
=
"demo-section k-content wide"
>
<
kendo-toolbar
name
=
"ToolBar"
>
<
toolbar-items
>
<
item
type
=
"CommandType.Button"
icon
=
"add"
text
=
""
click
=
"buttonClick"
/>
</
toolbar-items
>
</
kendo-toolbar
>
</
div
>
<
kendo-grid
name
=
"grid"
height
=
"550"
>
<
datasource
page-size
=
"20"
type
=
"DataSourceTagHelperType.Custom"
custom-type
=
"odata"
batch
=
"true"
>
<
transport
>
</
transport
>
<
schema
>
<
model
id
=
"ProductID"
>
<
fields
>
<
field
name
=
"ProductName"
></
field
>
<
field
name
=
"UnitPrice"
type
=
"number"
></
field
>
<
field
name
=
"UnitsInStock"
type
=
"number"
></
field
>
</
fields
>
</
model
>
</
schema
>
</
datasource
>
<
editable
mode
=
"incell"
/>
<
pageable
button-count
=
"5"
refresh
=
"true"
page-sizes
=
"new int[] { 5, 10, 20 }"
>
</
pageable
>
<
toolbar
>
<
toolbar-button
name
=
"create"
text
=
"Add new record"
></
toolbar-button
>
<
toolbar-button
name
=
"save"
text
=
"Save Changes"
></
toolbar-button
>
<
toolbar-button
name
=
"cancel"
text
=
"Cancel Changes"
></
toolbar-button
>
</
toolbar
>
<
columns
>
<
column
field
=
"ProductName"
title
=
"Product Name"
width
=
"240"
/>
<
column
field
=
"UnitPrice"
title
=
"Unit Price"
/>
<
column
field
=
"UnitsInStock"
title
=
"Units In Stock"
/>
<
column
field
=
"Discontinued"
title
=
"Discontinued"
width
=
"150"
/>
<
column
>
<
commands
>
<
column-command
text
=
"Delete"
name
=
"destroy"
></
column-command
>
</
commands
>
</
column
>
</
columns
>
</
kendo-grid
>
<
script
>
function buttonClick(e) {
alert("Button Clicked");
}
</
script
>
I am having dockerized Asp.Net Core application and using telerik UI for Asp.Net Core licensed NuGet Package by creating Telerik Package Source with physical path on my disk for nupkg file. All development was going well in debug mode, but when I tried to make a release, its giving the error - Unable to find package Telerik.UI.for.AspNet.Core with version >= 2018.2.620. Then it says that Found 1 version in nuget.org with Version 2016.3.914.
I don't think I should use this older version from nuget.org and moreover I will get trial version there.
Please suggest, if I am missing some steps to reference it properly.
Hi,
I'm using Kendo professional for Asp.net Core.
I got the error in "Session.GetObjectFromJson<IList< " and "Session.SetObjectAsJson( "
SeverityCodeDescriptionProjectFileLineSuppression State
ErrorCS1061'ISession' does not contain a definition for 'GetObjectFromJson' and no accessible extension method 'GetObjectFromJson' accepting a first argument of type 'ISession' could be found (are you missing a using directive or an assembly reference?)
I tried to fix by install Session from Nuget. but I can't find any package called Session in Nuget. Thank you if you can help.
ProductService.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Http;
using Kendo.Mvc.Examples.Extensions;
namespace Kendo.Mvc.Examples.Models
{
public class ProductService : BaseService, IProductService
{
private static bool UpdateDatabase = false;
private ISession _session;
public ISession Session { get { return _session; } }
public ProductService(IHttpContextAccessor httpContextAccessor)
{
_session = httpContextAccessor.HttpContext.Session;
}
public IEnumerable<ProductViewModel> Read()
{
return GetAll();
}
public IList<ProductViewModel> GetAll()
{
using (var db = GetContext())
{
var result = Session.GetObjectFromJson<IList<ProductViewModel>>("Products");
if (result == null || UpdateDatabase)
{
var categories = db.Categories.ToList();
result = db.Products.ToList().Select(product =>
{
var category = categories.First(c => product.CategoryID == c.CategoryID);
return new ProductViewModel
{
ProductID = product.ProductID,
ProductName = product.ProductName,
UnitPrice = product.UnitPrice.HasValue ? product.UnitPrice.Value : default(decimal),
UnitsInStock = product.UnitsInStock.HasValue ? product.UnitsInStock.Value : default(int),
QuantityPerUnit = product.QuantityPerUnit,
Discontinued = product.Discontinued,
UnitsOnOrder = product.UnitsOnOrder.HasValue ? product.UnitsOnOrder.Value : default(int),
CategoryID = product.CategoryID,
Category = new CategoryViewModel()
{
CategoryID = category.CategoryID,
CategoryName = category.CategoryName
},
LastSupply = DateTime.Today
};
}).ToList();
Session.SetObjectAsJson("Products", result);
}
return result;
}
}
public void Create(ProductViewModel product)
{
if (!UpdateDatabase)
{
var products = GetAll();
var first = products.OrderByDescending(e => e.ProductID).FirstOrDefault();
var id = (first != null) ? first.ProductID : 0;
product.ProductID = id + 1;
products.Insert(0, product);
Session.SetObjectAsJson("Products", products);
}
else
{
using (var db = GetContext())
{
var entity = new Product();
entity.ProductName = product.ProductName;
entity.UnitPrice = product.UnitPrice;
entity.UnitsInStock = (short)product.UnitsInStock;
entity.Discontinued = product.Discontinued;
entity.CategoryID = product.CategoryID;
if (entity.CategoryID == null)
{
entity.CategoryID = 1;
}
if (product.Category != null)
{
entity.CategoryID = product.Category.CategoryID;
}
db.Products.Add(entity);
db.SaveChanges();
product.ProductID = (int)entity.ProductID;
}
}
}
public void Update(ProductViewModel product)
{
if (!UpdateDatabase)
{
var products = GetAll();
var target = products.FirstOrDefault(e => e.ProductID == product.ProductID);
if (target != null)
{
target.ProductName = product.ProductName;
target.UnitPrice = product.UnitPrice;
target.UnitsInStock = product.UnitsInStock;
target.Discontinued = product.Discontinued;
target.CategoryID = product.CategoryID;
target.Category = product.Category;
}
Session.SetObjectAsJson("Products", products);
}
else
{
using (var db = GetContext())
{
var entity = new Product();
entity.ProductID = product.ProductID;
entity.ProductName = product.ProductName;
entity.UnitPrice = product.UnitPrice;
entity.UnitsInStock = (short)product.UnitsInStock;
entity.Discontinued = product.Discontinued;
entity.CategoryID = product.CategoryID;
if (product.Category != null)
{
entity.CategoryID = product.Category.CategoryID;
}
db.Products.Attach(entity);
db.Entry(entity).State = EntityState.Modified;
db.SaveChanges();
}
}
}
public void Destroy(ProductViewModel product)
{
if (!UpdateDatabase)
{
var products = GetAll();
var target = products.FirstOrDefault(e => e.ProductID == product.ProductID);
if (target != null)
{
products.Remove(target);
}
Session.SetObjectAsJson("Products", products);
}
else
{
using (var db = GetContext())
{
var entity = new Product();
entity.ProductID = product.ProductID;
db.Products.Attach(entity);
db.Products.Remove(entity);
var orderDetails = db.OrderDetails.Where(pd => pd.ProductID == entity.ProductID);
foreach (var orderDetail in orderDetails)
{
db.OrderDetails.Remove(orderDetail);
}
db.SaveChanges();
}
}
}
}
}
Hello,
How to reload a timeline (with Kendo grid I can use grid.dataSource.read();)
robert