I'm binding an AutoComplete to data server-side and it may, conditionally, already have a value set. I want to make sure that the user cannot add values that are not in the list so I've added a script that searches the dataSource for the value before the form is submitted. The problem seems to be when the textbox is given a value server-side, so it's never typed in or searched client-side before submitting, the dataSource .view() and .data() are empty (so it thinks my text is invalid). How can I get my dataSource to include the data without the user typing in the textbox?
01.
@(Html.Kendo().AutoComplete()
02.
.Name(
"ac-selected-gym"
)
03.
.BindTo(Model.AvailableLocations)
04.
.DataTextField(
"GymName"
)
05.
.Filter(
"contains"
)
06.
.MinLength(1)
07.
.HtmlAttributes(
new
{ @
class
=
"form-control"
, data_selected_gym =
""
, aria_describedby =
"selectedGymHelp"
})
08.
.Placeholder(
"Select your gym"
)
09.
.Value(Model.AvailableLocations.Where(f => f.Id== Model.SelectedId).FirstOrDefault()?.GymName)
10.
.Events(e => e.Change(
"sso.saml2.onGymChange"
))
11.
)
01.
function
getSelectedGym($flnAc) {
02.
var
selectedGym;
03.
04.
var
value = $flnAc.value();
05.
var
gymData = $flnAc.dataSource.view();
//This actually appears to return only the current match (or nothing)
06.
07.
var
searchSource =
function
(dataSource, gymName) {
08.
var
matchedGym;
09.
for
(
var
x = 0, length = dataSource.length; x < length; x++) {
10.
if
(dataSource[x].GymName === gymName) {
11.
matchedGym = dataSource[x];
12.
break
;
13.
}
14.
}
15.
return
matchedGym;
16.
};
17.
18.
selectedGym = searchSource(gymData, value);
19.
20.
//dataSource.view() may not have our item in it e.g. if the textbox was pre-filled server-side rather
21.
//than typed client-side, so search the whole list if not found. (Couldn't find a way to tell the control to update its datasource)
22.
if
(!selectedGym) {
23.
gymData = $flnAc.dataSource.data();
24.
selectedGym = searchSource(gymData, value);
25.
}
26.
27.
return
selectedGym;
28.
}
As you can see I tried to work around .view() being empty but then found that .data() is also empty. I also tried triggering the change event on load, but it was still empty.
Hi,
im working with scheduler component, and when i need to add an event, I need restrict the slot when it´s already is used.
I have used occurrencesInRange method but I need to compare the hours too.
mainly my need is to restrict when I have the date and time busy, I have looked in examples and they only validate occurrence of day.
Thanks.
I have implemented a simple Kendo grid in ASP .Net Core which should bind the data on DataSoruce Read request. In actual it is not binding data in read request but binds the data whenever i click on 'refresh' icon under pagination. Below is my code -
<div class="grid-container">
@(Html.Kendo().Grid<CAMPv2.Models.AutoPoco.Role>()
.Name("RolesGrid")
.Columns(columns =>
{
columns.Bound(c => c.Name);
columns.Bound(c => c.NormalizedName);
columns.Bound(c => c.Description);
columns.Bound(c => c.Status);
})
.Scrollable()
.Sortable()
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(datasource => datasource
.Ajax()
.Read(read => read.Action("GetRoles", "Role"))
)
)
</div>
Below is code behind -
[HttpPost]
public IActionResult GetRoles([DataSourceRequest] DataSourceRequest request)
{
List<Role> _lrolePermissionDetails = _tableOperations.GetAll<Role>(ApplicationConstants.CONNECTOR_AUTOPOCOAUTH, "Role", _loggingService).ToList();
return Json(_lrolePermissionDetails.ToDataSourceResult(request));
}
Please let me know what i am missing here.
Thanks,
Naga
Hi Telerik,
When I use the "services.AddKendo();" command,the program gives the following message.
I have followed the instructions on your page, the situation has not changed.
I first tried it with version 2016.3.118, then I tried it with the latest promotional version, the message has not changed.
Best regards,
Mehmet Bingol
Exception Unhandled:
System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType:
Kendo.Mvc.Rendering.IKendoHtmlGenerator Lifetime: Transient ImplementationType: Kendo.Mvc.Rendering.KendoHtmlGenerator':
Could not load type 'Microsoft.AspNetCore.Mvc.Internal.ClientValidatorCache' from assembly 'Microsoft.AspNetCore.Mvc.Core, Version=3.1.5.0,
InvalidOperationException: Error while validating the service descriptor 'ServiceType: Kendo.Mvc.Rendering.IKendoHtmlGenerator Lifetime:
Transient ImplementationType: Kendo.Mvc.Rendering.KendoHtmlGenerator': Could not load type 'Microsoft.AspNetCore.Mvc.Internal.ClientValidatorCache'
from assembly 'Microsoft.AspNetCore.Mvc.Core, Version=3.1.5.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
I'm trying to create a toolbar with a dropdown menu in my grid, similar to the demo shown here: https://demos.telerik.com/aspnet-core/grid/toolbar-template.
I can not find any information on doing it with tag helpers.
How get value from inputbox of selected checkboxitem(and subitems)? I can get label of checked item(item.Name), but i don't now how get value of inputbox.
<script id="treeview_distribute_template" type="text/kendo-ui-template">
<table>
<tbody>
<tr>
<td width="500px;">
#= item.Name #
</td>
<td >
<input id='comment_input' type='text' style="width:500px;" />
</td>
</tr>
</tbody>
</table>
</script>
function getCheckedItems(treeview) {
var nodes = treeview.dataSource.view();
return getCheckedNodes(nodes);
}
function getCheckedNodes(nodes) {
var node, childCheckedNodes;
var checkedNodes = [];
for (var i = 0; i < nodes.length; i++) {
node = nodes[i];
if (node.checked) {
checkedNodes.push(node);
}
if (node.hasChildren) {
childCheckedNodes = getCheckedNodes(node.children.view());
if (childCheckedNodes.length > 0) {
checkedNodes = checkedNodes.concat(childCheckedNodes);
}
}
}
return checkedNodes;
}
Hello,
Looking for an easy solution to enable/disable all grid rows based on other values/selections on the page.
The following selectable parameters for the grid gives me exactly what I need but I need to be able to configure the grid based on the user's input values on the page.
.Columns(columns => {
columns.Bound(e => e.Id).Hidden();
columns.Select()
.Width("20px");
columns.Bound(e => e.Name)
.Title("Name")
.Width("400px");
columns.Bound(c => c.Description)
.Title("Description")
.Width("400px");
})
.Selectable(select => select
.Mode(GridSelectionMode.Single)
.Type(GridSelectionType.Row)
)
I've tried using the following jquery to toggle the rows, with no luck. 'enabled' is the parameter passed to the function.
var grid = $('#grid').data('kendoGrid');
grid.items().each(
function (index, value) {
$(value).find('.k-checkbox').attr('disabled', !enabled);
}
);
Any suggestions on how I can achieve the functionality needed with the grid component?
Thanks.
Jason