Telerik Forums
UI for ASP.NET MVC Forum
3 answers
597 views

Hello,

I am stacked with this problem since 4 days.

I have two treeviews, the data of the first one is retrieved from my database as bellow :

@(Html.Kendo().TreeView()
                  .Name("treeview-left")
                  .Events(events => events
                  .DragEnd("HierarchyDragEnd"))
                  .HtmlAttributes(new { style = "height: 100%;" })
                  .DataTextField("name")
                  .DragAndDrop(true)
                  .DataSource(source => source
                      .Model(m => m
                          .Id("itemId")
                          .HasChildren("haschildren")
                          )
                      .Read(read => read
                          .Action("GetCatalog", "ItemsSelection")))
                          .ExpandAll(true)
            )

and the second treeview is empty, but i need to drag and drop items on it from the first tree and save in database :

 

@(Html.Kendo().TreeView()
                 .Name("treeview-right")
                 .Events(events => events
                 .DragEnd("HierarchyDragEnd"))
                 .HtmlAttributes(new { style = "height: 100%;" })
                 .DragAndDrop(true)
                 .DataTextField("name")
                 .DataSource(source => source
                             .Model(m => m
                                 .Id("itemId")
                                 .HasChildren("haschildren")
                                 )
                             )
 
                 )

 I use the script bellow to get the information from the first tree  but the script works just in case if i do drag and drop in the same tree:

function HierarchyDragEnd(e) {
        setTimeout(function () {
            var originDataItem = $("#treeview-left").data('kendoTreeView').dataItem(e.sourceNode);
            var originNodeId = originDataItem.id;
            var originNodeText = originDataItem.name;
 
 
            var destinationDataItem = $("#treeview-right").data('kendoTreeView').dataItem(e.destinationNode);
            var destinationNodeId = destinationDataItem.id;
            var destinationNodeText = destinationDataItem.name;
            destinationDataItem.add(originDataItem);
            var dropPosition = e.dropPosition;
 
            alert("Origin ID: " + originNodeId +
                                "\nOrigin Text: " + originNodeText +
                                "\nDestination ID: " + destinationNodeId +
                                "\nDestination Text: " + destinationNodeText +
                                "\nDrop Position: " + dropPosition);
        }, 100);
    }

 

Can someone pease help me to get all the information i need to save the dropped items in my database, maybe i am not using the right events or something else.

 

Thank you for your help.

Ivan Danchev
Telerik team
 answered on 22 Feb 2018
3 answers
275 views

<script id="SCTemplate" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<SCVM>()
          .Name("grid_#=SCartID#") // template expression, to be evaluated in the master context
          .Columns(columns =>
          {
              columns.Bound(c => c.ci.SCID).Hidden().HtmlAttributes(new { @id = "SCID" });
              columns.Bound(c => c.ci.FN).Title("Name");
              columns.Bound(c => c.ci.IN).Hidden(true);
              columns.Bound(c => c.ci.FN).Title("Item Number").Width(150);
              columns.Bound(c => c.ci.IsDO).Title("Order Type").ClientTemplate("#if(convertToBoolean(cosci)){#<span class='glyphicon glyphicon-envelope'>hello</span#}#").HtmlAttributes(new { @class = "js-bl" }) ;

 

 

The above is a code snippet from a Hierarchical Grid Template. What I am attempting to do is show an icon based on the value of "cosci". The issue is, this value is null. The type of this object is string. But when the page is hit, the value is gone. My Previous attempts had me set the object type to boolean. In all cases, it always came back as null. Interestingly enough, the c.ci.IsDO is "true", and it's type is boolean. Is it possible to have conditional statements in a child template? Please provide source files or a link to documentation that will shed light on the issue; but not http://demos.telerik.com/aspnet-mvc/grid/, as that link does not address the issue. 

FWIW, the convertToBoolean is a function I was using in attempt to change the types to achieve my desired result(s), this fails, because the sequence in which the objects are loaded into the DOM is unexpected.

 

Thanks.

Angel Petrov
Telerik team
 answered on 22 Feb 2018
1 answer
212 views

I am trying to enable range filtering using the EnableRangeFiltering property on a Grid column. The ShippedDate column in the following example demonstrates how to do it using webforms and server side binding, but I need an example using Razor and Ajax client side binding.

https://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/basic-filtering/defaultcs.aspx?show-source=true

Can you point me in the right direction?

Georgi
Telerik team
 answered on 22 Feb 2018
3 answers
859 views
I have a grid with an image column to show if there is an error or not.  If this is an error, I would like to display a tooltip with a message when the user hovers over the image.  The message would be from c.ErrorMessage.

Is there a sample on how to do this?  I searched and could not find one.

@(Html.Kendo().Grid<GridLineItem>().Name("grid").Columns(columns =>
              {
                    columns.Bound(c => c.ReportName).Title("Status").ClientTemplate(
                        "# if (HasError == true) { #" +
                            "<img src='" + Url.Content("Images/error.png") + "'/>" +
                        "# } else { #" +
                              "<img src='" + Url.Content("Images/success.png") + "'/>" +
                        "# } #"
                    );
                                )
Stefan
Telerik team
 answered on 22 Feb 2018
7 answers
955 views
Hello!
I have grid, which contains ClientDetailTemplateId("//here template with Grid -> " MyGridChild"...
If I create new object in MyGridChild, I want get Id him Parent 
Please help

Stefan
Telerik team
 answered on 22 Feb 2018
2 answers
574 views

Hey there guys and girl, i seem to be having a bit of an issues with the KENDO multi-select list when using it in a bootstrap modal. I have a simple form (_CreatePartial) that is used to add a new person to the. When the form is opened the first time, the multi-select list (car and phone ) load and appear properly but if you close the modal and re-open it, the multi-select lists don't load again.I don't know what exactly could be causing this, I am using the latest version of KENDO (2018.1.117) and latest version of bootstrap-3 (3.3.7). I have attached pictures to show what i see. Thanks for the help

 

 

Chinonso
Top achievements
Rank 1
 answered on 20 Feb 2018
4 answers
1.2K+ views

Hello,

Since updating to the latest version of UI for MVC, I've been having issues with DropdownListFor. Everything seems to work fine i.e. load the data and displaying it fine when you click on the icon to open the popup. However, when you select a value, the text displayed is [object Object]. I have no idea why this is and I have searched around for a solution to no avail. I would really appreciate some help on this issue. Below is a sample of my code:

@{
                        Html.Kendo().DropDownListFor(m => m.Centres)
                            .Name("cboCentres")
                            .DataTextField("CentreName")
                            .DataValueField("CentreId")
                            .OptionLabel(new
                            {
                                CentreName = "All",
                                CentreId = 0
                            })
                            .DataSource(ds =>
                            {
                                ds.Read(r => r.Url(Url.HttpRouteUrl("DefaultApi", new { controller = "Lookup", action = "GetCentres" })).Type(HttpVerbs.Get));
                            })
                            .Events(e =>
                            {
                                e.Change("cboCentres_SelectedValueChanged");
                            })
                            .Value("0")
                            .Render();
                    }

 

Below is my code for getting the data using WebApi:

public async Task<HttpResponseMessage> GetCentres() => Request.CreateResponse(HttpStatusCode.OK, await _CentreServices.GetCentres(), Configuration.Formatters.JsonFormatter);

 

As an aside, another minor issue I am having is with the grid. Despite the grid displaying data, at the bottom right of it, I get the text "No items to display" instead of the previous "5 of 10 items" for example.

Regards

Gez
Top achievements
Rank 1
 answered on 20 Feb 2018
5 answers
181 views

Hi,

I cannot seem to get the DataSpriteCssClassField to work correctly.  Here is the controller supplied class for each node...

01.public class DataDictionary_Categories : IStringIDDescription
02.{
03. 
04.    [DataMember]
05.    [XmlAttribute]
06.    public string CategoryCode { get; set; } = string.Empty;
07. 
08.    [DataMember]
09.    [XmlAttribute]
10.    public string TaxonomyCode { get; set; } = string.Empty;
11. 
12.    [DataMember]
13.    [XmlAttribute]
14.    public string Taxonomy { get; set; } = string.Empty;
15. 
16.    [DataMember]
17.    [XmlAttribute]
18.    public string Parent { get; set; } = string.Empty;
19. 
20.    [DataMember]
21.    [XmlAttribute]
22.    public string Description { get; set; } = string.Empty;
23. 
24.    [DataMember]
25.    [XmlAttribute]
26.    public string DataSpriteCSSClass { get { return ("glyphicon glyphicon-folder-close"); } set { } }
27. 
28.    [DataMember]
29.    [XmlAttribute]
30.    public int ComponentCount { get; set; } = 0;
31. 
32.    [DataMember]
33.    [XmlAttribute]
34.    public bool HasChildren
35.    {
36.        get
37.        {
38.            return (ComponentCount == 0);
39.        }
40. 
41.        set { }
42.    }
43. 
44.        public DataDictionary_Categories()
45.    {
46. 
47.    }
48.}

 

Here is the TreeView setup...

01.@(Html.Kendo().TreeView()
02.    .Name("CategoryTree")
03.    .TemplateId("TreeViewTemplate")
04.    .HtmlAttributes(new { })
05.    .DataTextField("Description")
06.    .AutoScroll(false)
07.    .LoadOnDemand(true)
08.    .Events(e => e.Select("OnCategorySelected"))
09.    .Events(e => e.Expand("OnCategoryExpand"))
10.    .Events(e => e.Collapse("OnCategoryCollapse"))
11.    .Animation(true)
12.    .DataSpriteCssClassField("DataSpriteCSSClass")
13.    .DataSource(d => d
14.        .Model(m => m
15.            .Id("CategoryCode")
16.            .HasChildren("HasChildren")
17.        )
18.        .Read(read => read.Action("ListSubCategories", "Services"))
19.        .Events(e => e.RequestEnd("OnCategoryRequestEnd"))
20.        .Events(e => e.RequestStart("OnCategoryRequestStart"))
21.))

I am trying to use the BootStrap glyph icons folder open/folder close glyphs. I have the glyhs working elsewhere.  It seems that the TreeView does not recognize this kind of thing.  Am I missing something?

Ivan Danchev
Telerik team
 answered on 20 Feb 2018
2 answers
317 views

Short version:

In a line series chart I have tooltips. These show all the time when the mouse is nowhere near an actual point on the chart. Seems no matter where my mouse is on a like I will see the tooltip for the point that is closest to my mouse. I want to be required to actually hover over the real data point on the chart to get the tooltip, not the line itself.

 

Longer version:

Open to suggestions if there is a better way. In the attached photo, you can see a chart that shows my customer gains and losses for a given period. The period is filterable. The "Maximize" button in the upper right doubles the chart width, and uses JavaScript to recalculate the step if needed (i.e. if there are too many data points to see all at once) and redraws the chart. When the user hovers over a data metric, they see a customized tooltip that lets them investigate the data that created the chart. This is a new Kendo window that pops up and contains a Kendo grid. The grid contains the exact number of customers in the metric they clicked on.

The ultimate problem is that while trying to navigate my mouse to the "Customer List" link I end up getting a new tooltip before I get there. It's too tough to use. So I want to only show a tooltip when actually hovering over the data point circle. If there's a better way I would listen to suggestions.

Paul
Top achievements
Rank 1
 answered on 19 Feb 2018
1 answer
502 views

I've seen several somewhat related threads, but none have helped me. When I click edit and then cancel, the item is removed from the grid (not the database). What is different about this scenario is I am using a composite key EventId + NameId + LocationId where each record will have either a NameId or a LocationId, but not both.

When I step through the code, my popup is displayed and bound as expected. When I click the cancel button it removes my edited item from the grid. I've tried jumping into the datasource change and sync events and doing an e.preventDefault() when I know this is the cancel of an edit, but that does not work (record disappears after that). Is there any spot I can jump in and intercept the removal of the item? Or is there something special I need to configure when using a composite key where one part will be null or zero? I get it that kendo must be thinking I am cancelling an insert instead of an update and it is probably related to my composite key use. My other grids work fine. Thanks.

 

            @(Html.Kendo().Grid<ContactViewModel>().Name("contactGrid")
                  .Columns(column =>
                  {
                      column.Template(t => { }).Title("Edit").Width(10)
                          .ClientTemplate(@"<a class='btn btn-info btn-xs k-grid-edit' title='Edit this contact.'><i class='fa fa-edit'></i></a>");
                      column.Bound(p => p.IncidentID).Hidden(true);
                      column.Bound(p => p.NameID).Hidden(true);
                      column.Bound(p => p.LocationID).Hidden(true);

                      ...

                  })
                  .Editable(editable => editable.Mode(GridEditMode.PopUp)
                      .TemplateName("EventContact")
                  .Filterable().Sortable().Pageable().ColumnMenu()
                  .Events(ev =>
                  {
                      ev.Edit("onContactGridEdit");
                  })
                  .DataSource(dataSource => dataSource
                      .Ajax()
                      .PageSize(10)
                      .Model(m =>
                      {
                          m.Id(c => new { c.IncidentID, c.NameID, c.LocationID });
                          m.Field(c => c.IncidentID).DefaultValue(Model.IncidentID);
                      })
                      .Read(read => read.Action("Read", "Contact", new { incidentID = Model.IncidentID }))
                      .Create(update => update.Action("Create", "Contact"))
                      .Update(update => update.Action("Update", "Contact"))
                      .Destroy(update => update.Action("Delete", "Contact"))
                  .Events(events =>
                  {
                      events.Change("incidentUpdate.onDataSourceChange");
                  })  )  )

            function dataSourceChange(e) {

                if (e.action === "remove" && !e.items[0].ContactIsNew) {   // this is a field I set to determine if it is a create or update
                    e.preventDefault();
                }
            }

            function dataSourceSync(e) {

                if (e.action === "remove" && !e.items[0].ContactIsNew) {   // this is a field I set to determine if it is a create or update
                    e.preventDefault();
                }
            }

Steve
Top achievements
Rank 1
 answered on 19 Feb 2018
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
Dialog
MultiColumnComboBox
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
Security
ColorPicker
DateRangePicker
Wizard
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
DropDownButton
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
LLM Kit
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?