TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aakash N
NA
166
19.5k
Cascading kendo dropdownlist => kendo dropdowntree
Oct 17 2018 1:12 PM
I am using Kendo UI for asp.net core, presently I'm trying to load the values of kendo dropdowntree based on kendo dropdownlist selected value. The aim is to load dropdowntree with its child nodes. But, only the first parent node with all the children are loaded (node1 appends all other children from other nodes2,3)
Cascades from dropdownlist
<label
class
=
"nav-label"
>Supplier</label>
<div>
@(Html.Kendo().DropDownList()
.Name(
"supplier-dropdown"
)
.DataTextField(
"SupplierOrganizationName"
)
.DataValueField(
"MasterId"
)
.ValueTemplate(
"<text><span>#: data.MasterId #</span> - <span>#: data.SupplierOrganizationName #</span></text>"
)
.Template(
"<text><span>#: data.MasterId #</span> - <span>#: data.SupplierOrganizationName #</span></text>"
)
.Events(e =>
{
e.Change(
"onSupplierSelect"
);
})
.DataSource(source =>
{
source.Read(read =>
{
read.Action(
"GetSuppliers"
,
"Home"
);
});
}).OptionLabel(
"Select Supplier..."
).HtmlAttributes(
new
{ @
class
=
"nav-supplier-dropdown"
}))
</div>
onSupplierSelect event loads data to dropdowntree
var
masterId =
''
;
function
onSupplierSelect(e) {
masterId = $(
'#supplier-dropdown'
).val();
var
url =
'@Url.Action("GetDivisionLocation", "Home")'
+
'/'
+ masterId;
$.get(url,
function
(response) {
var
dropdowntree = $(
"#dropdowntree"
).data(
"kendoDropDownTree"
);
dropdowntree.dataSource(response);
});
}
function
additionalInfo() {
return
{
masterId: masterId
}
}
dropdowntree htmlHelper tag
$(document).ready(
function
() {
// create kendoDropDownTree from input HTML element
$(
"#dropdowntree"
).kendoDropDownTree({
placeholder:
"Select Divisions/ Locations..."
,
//template: kendo.template($("#dropdowntree-template").html()),
//valueTemplate: kendo.template($("#dropdowntree-value-template").html()),
autoWidth:
true
,
height:
"auto"
,
checkboxes: {
checkChildren:
true
},
filter:
"startswith"
,
checkAll:
true
,
autoClose:
false
,
//dataSource: response,
//dataTextField: ["divName", "locName"],
//dataValueField: "divId"
});
});
controller method which loads data
public
JsonResult GetDivisionLocation(String id)
{
List<RootObject> rootObjects =
new
List<RootObject>();
List<DivisionsLocationOption> divisionLocationOptions =
this
._supplierService.GetDivisionLocationCollections(
"507981"
, id);
var data = (from m
in
divisionLocationOptions
select m.masterId).Distinct();
foreach
(var itemTop
in
data)
{
var data1 = divisionLocationOptions.FirstOrDefault(cond => cond.masterId == itemTop);
RootObject rootObject =
new
RootObject
{
text = data1.parkerDivName,
expanded =
false
,
checkAll =
false
};
var data2 = divisionLocationOptions.Where(cond => cond.masterId == itemTop);
List<Item> items =
new
List<Item>();
foreach
(var item
in
data2)
{
items.Add(
new
Item
{
text = item.parkerLocName
});
}
rootObject.items = items;
rootObjects.Add(rootObject);
}
return
Json(rootObjects);
}
Here, I want to load dropdowntree with nodes and its own children
Reply
Answers (
1
)
edit all td values in html table or webgrid
Pass Dropdown Value OnePage To another