How can we select the node that is clicked on by a right click event? I am trying to pass the selected node's id on a context menu select event but unless the user left clicks on the node to select it first, the last selected node information gets sent, if one was even selected.
This may be fairly basic, but I can't find any examples of this.
Thanks.
Hello,
I have a Kendo treeview which loads on demand and i am using hierarchial data. So it only loads children when clicked on node . everything works fine till my records are more than 3000. In Firefox the tree loads in 5 seconds. But in IE the browser hangs and never recovers.
This is how my treeview looks
@(Html.Kendo().TreeView()
.Name("objtreeView")
.HtmlAttributes(new { style = "height:700px;overflow-x:hidden;" })
.DataImageUrlField("imageUrl")
.DataTextField("Text")
.LoadOnDemand(true)
.Template(
"# if (item.AdditionalImageUrl !='') { #" +
"<img src='#= item.AdditionalImageUrl#'/> #:item.Text#" +
"# } else {#" +
" #:item.Text#" +
"# }#"
)
.Events(events => events
.Select("onSelect")
)
.DataSource(dataSource => dataSource
.Read(readtree => readtree
.Action("ReadObjects", "Objekt").Data("addSearch")
)
)
)
And ReadObjects Looks like this
public JsonResult ReadObjects(string Id, string)
{
DataSet ds = cObjData.ReadObjects();
if ((ds != null) && ds.Tables.Count > 0)
{
//Alle Zeilen durchgehen
foreach (DataRow r in ds.Tables[0].Rows)
{
result.Add(new { Text = strText, id = r["ObjectID"].ToString(), Color = hexColor, hasChildren = bhaschildren, imageUrl = Url.Content(strImage), AdditionalImageUrl = "" });
}
return Json(result.AsQueryable(), JsonRequestBehavior.AllowGet);
}
In production sometimes we have 10,000 records to load. Any help is appreciated
Thanks
Anamika
Hello,
I'm looking for add a target blank to an url but i wonder how to do it:
@(Html.Kendo().TreeView()
.Name("treeview-right")
.DragAndDrop(true)
.Items(treeview =>
{
treeview.Add().Text("Accès Mirakl")
.Url("http://google.com")
.ImageUrl(Url.Content("~/Content/images/internet_16x16.png"));
treeview.Add().Text("Wiki Mirakl")
.Url("http://goole.fr")
.ImageUrl(Url.Content("~/Content/images/ampoule_16x16.png"));
})
Hi,
I have a Treeview with a specific hierarchy. The parent and children nodes have checkboxes.
The parent node should be completely checked if all the children nodes under them are checked and it should be partially checked if the children nodes are not completely checked.
But in my case, the parent node which is having partially checked children nodes is not highlighted or partially checked when the treeview loads initially. Once the parent node has been read, the node is partially checked. I need the parent node to be partially checked if it has partially checked children nodes when the Treeview loads for the first time itself.
I have attached the screenshot too.
Thanks in advance.
<
div
>
@(Html.Kendo().TreeView()
.Name("treeview")
.DataTextField("DisplayValue")
.DataSource(dataSource => dataSource
.Read(read => read
.Action("CategoryTree", "Category")
)
)
)
</
div
>
.Template("#: item.DisplayValue # " + @Html.ActionLink("Update", "Update", new { id = "newId" })
.ToHtmlString().Replace("newId", "#: item.id #")
)<
div
style
=
"padding-top: 10px;"
>
@(Html.Kendo().TreeView()
.Name("treeview")
.DataTextField("DisplayValue")
.DataSource(dataSource => dataSource
.Read(read => read
.Action("CategoryTree", "Category")
)
)
.Template("#: item.DisplayValue # " + @Html.ActionLink("Update", "Update", new { id = "newId" })
.ToHtmlString().Replace("newId", "#: item.id #") + " | " + @Html.ActionLink("Deactivate", "Deactivate", new { id = "newId" })
.ToHtmlString().Replace("newId", "#: item.id #"))
)
</
div
>
I have a treeview set up as below ("treeview"), and the rendered checkboxes are not styled according to the theme (bootstrap). If I set up another treeview with local data ("treeview1"), they render as themed. Any hints as to how i can get the checkboxes to adhere to the theme when using a datasource?
NOT THEMED:
@(Html.Kendo().TreeView()
.Name("treeview")
.Checkboxes(checkboxes => checkboxes.Name("checkedCategories")
.CheckChildren(true))
.Events(events => events.Check("onCheck"))
.DataTextField("description")
.DataSource(dataSource => dataSource
.Model(m => m.HasChildren("HasChildren").Children("Children"))
.Read(read => read.Action("GetFilters", "ProductList")))
)
THEMED:
@(Html.Kendo().TreeView()
.Name("treeview1")
.Checkboxes(checkboxes => checkboxes.Name("checkedCategories"))
.Items(treeview =>
{
treeview.Add().Text("Asset Class").Id("1-1")
.Expanded(true)
.Items(category =>
{
category.Add().Text("My first thing").Id("2-1");
category.Add().Text("My Second Thing").Id("2-2");
});
}))
I am attempting to write the onDrop event:
function onTreeDrop(e) {
var treeview = $("#treeview").data("kendoTreeView");
var p = e.dropPosition;
sn = treeview.dataItem(e.sourceNode);
dn = treeview.dataItem(e.destinationNode);
psn = treeview.parent(e.sourceNode);
pdn = treeview.parent(e.destinationNode);
if (p == "over") {
if (dn.IsDept) {
treeview.append(sn, pdn);
}
else {
treeview.append(sn, dn);
}
e.setValid(true);
}
else if (p == "before") {
}
else if (p == "after") {
}
}
when I do a drop over I get the following error:
kendo.all.js:78326
Uncaught TypeError: t.children is not a function
at kendo.all.js:78326
at init.append (kendo.all.js:79643)
at init.onTreeDrop (Index:497)
at init.trigger (kendo.all.js:124)
at Object.drop (kendo.all.js:78557)
at init.dragend (kendo.all.js:78269)
at init.i (jquery-1.10.2.min.js:21)
at init.trigger (kendo.all.js:124)
at init._trigger (kendo.all.js:23904)
at init._end (kendo.all.js:23881)
when I follow the error to kendo.all.js:78326 the object has node.children. My own Model has a Children property. Perhaps the two "children" are conflicting?
public
class
TreeMainItem
{
private
IList<TreeSubItem> _SubItems;
private
bool
_hasChildren =
true
;
public
TreeMainItem()
{
_SubItems =
new
List<TreeSubItem>();
}
public
int
ItemIndex {
get
;
set
; }
public
string
Title {
get
;
set
; }
public
string
CssClass {
get
;
set
; }
public
string
TargetUrl {
get
;
set
; }
public
string
IconUrl {
get
;
set
; }
public
bool
hasChildren
{
get
{
return
this
._hasChildren; }
set
{
this
._hasChildren = value; }
}
public
IList<TreeSubItem> SubItems
{
get
{
return
this
._SubItems; }
set
{
this
._SubItems = value; }
}
}
public
class
TreeSubItem
{
private
bool
_hasChildren =
false
;
public
int
ItemIndex {
get
;
set
; }
public
string
Title {
get
;
set
; }
public
string
CssClass {
get
;
set
; }
public
string
TargetUrl {
get
;
set
; }
public
string
IconUrl {
get
;
set
; }
public
bool
hasChildren
{
get
{
return
this
._hasChildren; }
set
{
this
._hasChildren = value; }
}
}
http://dojo.telerik.com/IGujU/3
How to make it so the hint can only be moved within the boundaries of the parent?
And how to autoscroll if I have a very long list, like i'm dragging the last item and when the hint is on top most of the visible viewport it will scroll up?
I want to render a treeview and a tabstrip within a page. This tabstrip will have three tabs each of which will render a grid inside it.
<
div
class
=
"row"
>
<
div
class
=
"demo-section narrow tree-view"
>
<
div
>
@(Html.Kendo().TreeView()
.Name("AssetTreeView")
.DataTextField("Name")
.DataSource(dataSource => dataSource
.Read("ReadCategories", "Software")
.Model(categoriesModel => categoriesModel
.Id("Id")
.Children(clientHw => clientHw
.Read("ReadClientHWs", "Software")
.Model(clientHWModel => clientHWModel.Id("Id"))
)
)
)
.Events(events => events
.Select("onNodeSelected"))
)
</
div
>
</
div
>
<
div
class
=
"demo-section wide grid"
>
@(Html.Kendo().TabStrip()
.Name("SoftwareTabStrip")
.Animation(animation =>
animation.Open(effect =>
effect.Fade(FadeDirection.In)))
.Items(tabstrip =>
{
tabstrip.Add()
.Text("Blacklisted")
.Selected(true)
.ImageUrl("~/Content/Images/32x32/traffic-light-red.png")
.ImageHtmlAttributes(new { style = "width: 32px; height: 32px; padding: 3px;" })
.Content(@<
text
>Blacklisted is bad!
@(Html.Kendo().Grid<
MyIT.ModelsInterfaces.Models.MyIT.Software
>()
.Name("BlacklistedSoftwareGrid")
.Columns(columns =>
{
columns.Bound(s => s.Publisher).Width(250);
columns.Bound(s => s.SoftwareName).Width(250);
columns.Bound(s => s.Version).Width(100);
columns.Bound(s => s.Description).Width(400);
})
.NoRecords("No blacklisted software installed...")
.Pageable()
.Sortable()
.Scrollable(x => x.Height(400))
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("GetRedSoftware", "Software").Data("additionalData"))
)
.Events(events => events
.DataBound("onBlacklistedBound")
.DataBinding("onDataBinding"))
)
</
text
>);
tabstrip.Add()
.Text("Other Software")
.ImageUrl("~/Content/Images/32x32/traffic-light-yellow.png")
.ImageHtmlAttributes(new { style = "width: 32px; height: 32px; padding: 3px;" })
.Content(@<
text
>Yellow is allowed!
@(Html.Kendo().Grid<
MyIT.ModelsInterfaces.Models.MyIT.Software
>()
.Name("UnsupportedSoftwareGrid")
.Columns(columns =>
{
columns.Bound(s => s.Publisher).Width(250);
columns.Bound(s => s.SoftwareName).Width(250);
columns.Bound(s => s.Version).Width(100);
columns.Bound(s => s.Description).Width(400);
})
.NoRecords("No software available...")
.Pageable()
.Sortable()
.Scrollable(x => x.Height(400))
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("GetYellowSoftware", "Software").Data("additionalData"))
)
.Events(events => events
.DataBound("onUnsupportedBound")
.DataBinding("onDataBinding"))
)
</
text
>);
tabstrip.Add()
.Text("Supported")
.ImageUrl("~/Content/Images/32x32/traffic-light-green.png")
.ImageHtmlAttributes(new { style = "width: 32px; height: 32px; padding: 3px;" })
.Content(@<
text
>Green is supported!
@(Html.Kendo().Grid<
MyIT.ModelsInterfaces.Models.MyIT.Software
>()
.Name("SupportedSoftwareGrid")
.Columns(columns =>
{
columns.Bound(s => s.Publisher).Width(200);
columns.Bound(s => s.SoftwareName).Width(200);
columns.Bound(s => s.Version).Width(100);
columns.Bound(s => s.Description).Width(400);
})
.NoRecords("No software available...")
.Pageable()
.Sortable()
.Scrollable(x => x.Height(400))
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("GetGreenSoftware", "Software").Data("additionalData"))
)
.Events(events => events
.DataBound("onSupportedBound")
.DataBinding("onDataBinding"))
)
</
text
>);
})
)
</
div
>
</
div
>
The treeview should always return one node (HW Category) expanded with one of it's child node (ClientHW) selected.
Note: ReadClientHWs action method below will return node object with one of the property named "selected"
public class SoftwareController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult ReadCategories()
{
var categories = from category in _clientHWService.GetMajorAssetCategoriesOfUser(_myITService.GetCurrentUser())
select category;
return Json(_mapperService.MapToClientHWCategoryItems(categories),
JsonRequestBehavior.AllowGet);
}
public ActionResult ReadClientHWs(int id)
{
var clientHardwares = from hw in _clientHWService.GetMajorAssetsForUser(_myITService.GetCurrentUser())
where hw.UsedAsId.Equals(id)
select hw;
return Json(_mapperService.MapToClientHWItems(clientHardwares), JsonRequestBehavior.AllowGet);
}
public ActionResult GetGreenSoftware([DataSourceRequest] DataSourceRequest request, string computerName)
{
return Json(_softwareService.GetGreenSoftwares(computerName).ToDataSourceResult(request));
}
public ActionResult GetYellowSoftware([DataSourceRequest] DataSourceRequest request, string computerName)
{
return Json(_softwareService.GetYellowSoftwares(computerName).ToDataSourceResult(request));
}
public ActionResult GetRedSoftware([DataSourceRequest] DataSourceRequest request, string computerName)
{
return Json(_softwareService.GetRedSoftwares(computerName).ToDataSourceResult(request));
}
}
I successfully made the grid loads the correct data every time user click one of the ClientHW nodes. but I haven't been able to render the grid base on this selected node the first time the page load.
how can i accomplish this?