Hi!
How do i make so this code work?
The problem is that i doesent get out a SalonID value so i can redirect.
Here is the full code:
I also in want that when i type 1 letter in the autocomplet, the grid should filter directly & right now im only avalible to search/filter 1 column in my db, i want to choose several tables to be searchable.
Ty!
How do i make so this code work?
var
grid = $(
"#GridField"
).kendoGrid();
function
grid_selected(e) {
var
id;
grid.select().each(
function
() {
// CRASH HERE.. Doesent get a dataitem.
var
dataItem = grid.dataItem($(
this
));
id = dataItem.SalonID;
})
window.location.href =
"@Url.Action("
Details
", "
Salon
")"
+
"/"
+ id;
}
The problem is that i doesent get out a SalonID value so i can redirect.
Here is the full code:
<p>
@(Html.Kendo().AutoComplete()
.Name(
"searchField"
)
.DataTextField(
"SalonName"
)
.Filter(
"Contains"
)
.Placeholder(
"Search.."
)
.DataSource(dataSource =>
{
dataSource.Read(read =>
{
read.Action(
"GetAutoCompleteItems"
,
"Salon"
);
})
.ServerFiltering(
false
);
})
.Events(events => events.Change(
"autoComplete_selected"
))
)
</p>
<div id=
"Grid"
>
@(Html.Kendo().Grid(Model)
.Name(
"GridField"
)
.Columns(columns =>
{
columns.Bound(item => item.SalonID);
columns.Bound(item => item.Avtnr);
columns.Bound(item => item.SalonName);
columns.Bound(item => item.Street);
columns.Bound(item => item.ZipCode);
columns.Bound(item => item.City);
columns.Bound(item => item.Telephone);
columns.Bound(item => item.SalonEmail);
columns.Bound(item => item.Description);
columns.Bound(item => item.ContactPerson);
})
.ColumnMenu()
.Groupable()
.Pageable()
.Sortable()
.Resizable(resize => resize.Columns(
true
))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action(
"Read"
,
"Salon"
))
.ServerOperation(
false
)
)
.Events(events => events.Change(
"grid_selected"
))
)
</div>
<script type=
"text/javascript"
>
var grid = $(
"#GridField"
).kendoGrid();
function grid_selected(e) {
var id;
grid.select().each(function() {
var dataItem = grid.dataItem($(
this
));
// CRASH HERE.. Doesent get a dataitem.
id = dataItem.SalonID;
})
window.location.href =
"@Url.Action("
Details
", "
Salon
")"
+
"/"
+ id;
}
//
// Filter the grid when searching..
//
function autoComplete_selected(e) {
var value =
this
.value();
if
(value) {
grid.data(
"kendoGrid"
).dataSource.filter({ field:
"SalonName"
,
operator
:
"contains"
, value: value });
}
else
{
grid.data(
"kendoGrid"
).dataSource.filter({});
}
}
</script>
I also in want that when i type 1 letter in the autocomplet, the grid should filter directly & right now im only avalible to search/filter 1 column in my db, i want to choose several tables to be searchable.
Ty!