Telerik Forums
UI for ASP.NET MVC Forum
1 answer
639 views

I'm trying to use the Telerik MVC TreeView control with the kendo.data.HierarchicalDataSource control and local data.

In samples for the Kendo Treeview, they point to the Javascript datasource like this:

dataSource: homogeneous

What syntax do I use in the fluent MVC TreeView to reference data that's held in a JavaScript variable?

Showing my hierarchical data below.

Thanks,

Ken

{ 
   "bodyType":"ESTATE",
   "capCode":"VWTI20SE5EDTM4",
   "capID":null,
   "co2Emissions":"167",
   "colour":"SILVER",
   "cylinderCapacity":"1968 cc",
   "dateFirstUsed":"23 July 2009",
   "dateOfFirstRegistration":"23 JULY 2009",
   "description":"2009 Volkswagen Tiguan Se Tdi (140) 4MOTION, 1968CC Diesel, 5DR, Manual",
   "engineSize":"1968CC",
   "fuel":"Diesel",
   "fuelType":"DIESEL",
   "imported":"false",
   "insuranceGroup":"09",
   "licencePlate":"mt09nks",
   "make":"Volkswagen",
   "model":"Tiguan",
   "mot":true,
   "motDetails":"Expires: 28 April 2017",
   "motTestReports":[ 
      { 
         "motTestNumber":244794981138,
         "testResult":"Pass",
         "testDate":"29 April 2016",
         "odometerReading":80084,
         "expiryDate":"28 April 2017",
         "advisoryItems":[ 
 
         ],
         "failureItems":[ 
 
         ]
      },
      { 
         "motTestNumber":938552815158,
         "testResult":"Pass",
         "testDate":"22 April 2015",
         "odometerReading":74998,
         "expiryDate":"21 April 2016",
         "advisoryItems":[ 
 
         ],
         "failureItems":[ 
 
         ]
      },
      { 
         "motTestNumber":157384685012,
         "testResult":"Fail",
         "testDate":"25 March 2015",
         "odometerReading":74813,
         "expiryDate":"",
         "advisoryItems":[ 
            "Front Brake pad(s) wearing thin (3.5.1g)",
            "Front brake disc worn, pitted or scored, but not seriously weakened (3.5.1i)",
            "Rear brake disc worn, pitted or scored, but not seriously weakened (3.5.1i)",
            "Rear Brake pad(s) wearing thin (3.5.1g)",
            "Nearside Front Suspension arm rubber bush deteriorated but not resulting in excessive movement (2.4.G.2)",
            "Offside Front Suspension arm rubber bush deteriorated but not resulting in excessive movement (2.4.G.2)"
         ],
         "failureItems":[ 
            "Nearside Front Tyre tread depth below requirements of 1.6mm (4.1.E.1)",
            "Offside Front Tyre tread depth below requirements of 1.6mm (4.1.E.1)",
            "Front Brakes imbalanced across an axle (3.7.B.5b)",
            "Nearside Front Windscreen wiper does not clear the windscreen effectively (8.2.2)"
         ]
      },
      { 
         "motTestNumber":195455474181,
         "testResult":"Pass",
         "testDate":"24 June 2014",
         "odometerReading":63643,
         "expiryDate":"23 July 2015",
         "advisoryItems":[ 
 
         ],
         "failureItems":[ 
 
         ]
      },
      { 
         "motTestNumber":198414503254,
         "testResult":"Pass",
         "testDate":"23 July 2013",
         "odometerReading":52191,
         "expiryDate":"23 July 2014",
         "advisoryItems":[ 
 
         ],
         "failureItems":[ 
 
         ]
      },
      { 
         "motTestNumber":945398182180,
         "testResult":"Pass",
         "testDate":"6 July 2012",
         "odometerReading":308600,
         "expiryDate":"23 July 2013",
         "advisoryItems":[ 
 
         ],
         "failureItems":[ 
 
         ]
      }
   ],
   "numberOfDoors":"5",
   "numberOfSeats":"5",
   "price":"6465.0",
   "steering":"RHD",
   "transmission":"MANUAL",
   "typeApproval":"M1",
   "vin":"WVGZZZ5NZAW007903",
   "year":"2009",
   "yearOfManufacture":"2009"
}
Nencho
Telerik team
 answered on 27 Mar 2017
1 answer
186 views

I have tabstrip that is displaying a partial from a different controller/view area, but I cant get the post of the partial in the tabstrip to post back to the different controller

 

the View that the tab is in.

~/Areas/Secure/Views/Company/companyStaff.cshtml

display a view assocated to a different controller

tabstrip.Add().Text("Create Contact")
                  .Selected(false)
                  .Content(Html.Partial("~/Areas/Secure/Views/Contact/_ContactManagement.cshtml",  new WebSite.Library.Models.Contact() , new ViewDataDictionary { { "Id", "0" } }).ToHtmlString());

 

How can I get the partial in the tab to post back to its own controller post method

Ivan Danchev
Telerik team
 answered on 27 Mar 2017
4 answers
953 views

Hi,

I am using the Pdf export to print a grid. In the page header on each page I would like to have content from the model (or the ViewBag or some other way), in any case data that I can set in the method in the controller when I load the ViewModel for the page. I have found a lot of info about the page headers, but the page number is the only variable data I have seen.

I would like to show something like "Inventory as of Dec 3rd, report printed March 21st", so not only page number and today's date but other stuff too.

Is this possible and if so, can someone please point me in the right direction for info on this?

 

Best regards,

Henrik

Henrik
Top achievements
Rank 1
 answered on 27 Mar 2017
1 answer
1.4K+ views

How do i get the value of a Kendo Date Picker by class name. The reason being is because im using the name and id attributes for something else. As you can see below the class attribute is dynamic. Every other time ive selected a Kendo Date Picker, i've always used the ID attribute. Is it possible to select by class attribute?

@Html.Kendo().DatePicker()
              .Name("SurveyResponse.DateRes[" + @guid + "].Date")
              .Format("MM/dd/yyyy")
              .HtmlAttributes(new {
                       onkeydown = "javascript:return false;",
                       onblur = "ConditionalTextBox(" + @item.SurveyQuestionID + ",'datecontrol')",
                       @placeholder = "Your answer",
                       @required = "required",
                       @class = "IsConditionalTextBox_" + @item.SurveyQuestionID
                       })
Konstantin Dikov
Telerik team
 answered on 24 Mar 2017
1 answer
217 views

Greetings all,

 

I am attempting to have the same select list display on one page via MVC Display Templates. So far I've only been able to get one of the select lists to display at a time. Is this functionality not allowed. See my code example below:

 

    <div class="row">
        <div class="">@Html.DisplayFor(m => m.AgentSelector)</div>
    </div>
 
<div class="">
<p> a bunch of misc. data is here </p>
</div>
 
    <div class="row">
        <div class="">@Html.DisplayFor(m => m.AgentSelector)</div>
    </div>

 

The first one works. The second one does not. Is there a way to get this to work.

Ianko
Telerik team
 answered on 24 Mar 2017
1 answer
97 views
Hello~ I would like to make kendo window to show kendo grid cell detail. Actually, I worked fine, but kendo window show original value not foreign key as I set in kendo grid column. Is that possible to show foreign key value in kendo window instead of original value? thanks in advance~
Nikolay
Telerik team
 answered on 24 Mar 2017
1 answer
155 views

Hello,

I have used kendo scheduler for displaying schedule but not able see any event on scheduler and also not getting error as well.

please check attached images for reference. 

Thanks,

Vinal Patwa

 

Nencho
Telerik team
 answered on 24 Mar 2017
6 answers
3.6K+ views
Hi!

Is there any way to add dynamic default values? When I push the "Add row" button a new row with a new default value (max  value + 1) for count column should be added.

Example:

.ToolBar(toolbar => {
        toolbar.Create().Text("Add row");
    })
...
 .Model(model => {
            model.Id(n => n.ID);
            model.Field(c => c.count).DefaultValue(<this value needs to be max value + 1>);
            model.Field(c => c.count).Editable(false);
        })

I have tried to adding an event on .Events( e => e.Change("MyFunction"))  but the row adding is done after MyFunction event is fired.

/Malte

Randy
Top achievements
Rank 1
 answered on 24 Mar 2017
6 answers
1.1K+ views

How to customise row and column header in kendo spreadsheet 
Is there any Cell/Row template is available for kendo spreadsheet

Support for Item edit template

Support for different edit controls for different types of columns/rows

ullas
Top achievements
Rank 1
 answered on 24 Mar 2017
3 answers
666 views
I have a grid that display details of some items.  The grid has a custom command to open a window to display sub details of the selected item.  The grid that is displayed in the window that opens has inline editing turned on.  When I try to perform an update / create / delete, the Action is properly called, but the passed in model is null.
@(Html.Kendo().Grid<Carrier>()
      .Name("grid")
      .Columns(columns =>
          {
              columns.Bound(p => p.Name).Groupable(false).Width(125);
              columns.Bound(p => p.AuthorityReceived)
                     .Title("A")
                     .Filterable(false)
                     .Width(40)
                     .ClientTemplate("<input type='checkbox' disabled='disabled' #= AuthorityReceived ? checked='checked':'' # />");
              columns.Bound(p => p.W9Received)
                     .Title("W9")
                     .Filterable(false)
                     .Width(40)
                     .ClientTemplate("<input type='checkbox' disabled='disabled' #= W9Received ? checked='checked':'' # />");
              columns.Bound(p => p.InsuranceReceived)
                     .Title("Ins")
                     .Filterable(false)
                     .Width(40)
                     .ClientTemplate("<input type='checkbox' disabled='disabled' #= InsuranceReceived ? checked='checked':'' # />");
              columns.Bound(p => p.Phone1).Groupable(false).Title("Phone 1").Width(125);
              columns.Bound(p => p.Phone2).Groupable(false).Title("Phone 2").Width(125);
              columns.Bound(p => p.AfterHoursPhone).Groupable(false).Title("After Hrs #").Width(125);
              columns.Bound(p => p.Email).Groupable(false).Width(125);
              columns.Command(command => command.Custom("ViewComments").Click("showComments"));
          })
      .Groupable()
      .Pageable()
      .Sortable()
      .Scrollable()
      .Filterable()
      .Selectable()
      .Resizable(resize => resize.Columns(true))
      .Reorderable(reorder => reorder.Columns(true))
      .DataSource(
          dataSource => dataSource
                            .Ajax()
                            .PageSize(50)
                            .Read(read => read.Action("CarrierRead", "DataActions")))
      )
 
@(Html.Kendo().Window().Name("Comments")
      .Title("Comments")
      .Visible(false)
      .Modal(true)
      .Draggable(true)
      .Resizable()
      )
 
<script id="comments-template" type="text/x-kendo-template">
    <div id="details-container">
        <h3>#= Name #</h2>
    @(Html.Kendo().Grid<CarrierComment>()
          .Name("grid_#=CarrierId#")
          .Columns(columns =>
              {
                  columns.Bound(o => o.Comment);
                  columns.Bound(o => o.AddedBy).Width(150);
                  columns.Bound(o => o.TimeStamp).Format("{0:MM/dd/yyyy hh:mm tt}").Width(175);
                  columns.Command(command =>
                      {
                          command.Destroy();
                          command.Edit().UpdateText("Save");
                      }).Width(200);
              })
          .DataSource(
              dataSource =>
              dataSource
                  .Ajax()
                  .PageSize(5)
                  .Model(model => model.Id(p => p.CommentId))
                  .Create(update => update.Action("CommentCreate", "DataActions", new {carrierId = "#=CarrierId#"}))
                  .Update(update => update.Action("CommentUpdate", "DataActions"))
                  .Destroy(update => update.Action("CommentDelete", "DataActions"))
                  .Read(read => read.Action("CommentRead", "DataActions", new {carrierId = "#=CarrierId#"}))
          )
          .ToolBar(toolbar => toolbar.Create().Text("New Comment"))
          .Editable(editable => editable.Mode(GridEditMode.InLine))
          .Pageable()
          .Sortable()
          .Selectable()
          .Resizable(resize => resize.Columns(true))
          .Reorderable(reorder => reorder.Columns(true))
          .Scrollable()
          .ToClientTemplate())
    </div>
</script>
 
<script type="text/javascript">
    var detailsTemplate = kendo.template($("#comments-template").html());
 
    function showComments(e) {
        e.preventDefault();
 
        var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
        var wnd = $("#Comments").data("kendoWindow");
 
        wnd.content(detailsTemplate(dataItem));
        wnd.center().open();
    }
</script>
[HttpPost]
        public ActionResult CommentRead([DataSourceRequest] DataSourceRequest request, int carrierId)
        {
            try
            {
                var facade = new CarrierFacade();
                var comments = facade.GetAllComments(carrierId);
                return Json(comments.ToDataSourceResult(request));
            }
            catch (DbException ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return View("Error");
            }
        }
 
        [HttpPost]
        public ActionResult CommentCreate([DataSourceRequest] DataSourceRequest request, CarrierComment comment)
        {
            if (comment != null && ModelState.IsValid)
            {
                try
                {
                    var facade = new CarrierFacade();
                    facade.InsertComment(comment);
                }
                catch (DbException ex)
                {
                    ViewBag.ErrorMessage = ex.Message;
                    return View("Error");
                }
            }
 
            return Json(new[] {comment}.ToDataSourceResult(request, ModelState));
        }
 
        [HttpPost]
        public ActionResult CommentUpdate([DataSourceRequest] DataSourceRequest request, CarrierComment comment)
        {
            try
            {
                var facade = new CarrierFacade();
                facade.UpdateComment(comment);
                return Json(ModelState.ToDataSourceResult());
            }
            catch (DbException ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return View("Error");
            }
        }
 
        [HttpPost]
        public ActionResult CommentDelete([DataSourceRequest] DataSourceRequest request, CarrierComment comment)
        {
            try
            {
                var facade = new CarrierFacade();
                facade.DeleteComment(comment.CommentId);
                return Json(ModelState.ToDataSourceResult());
            }
            catch (DbException ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return View("Error");
            }
        }
If I move the Grid out of the window, the model that is passed to my Controller's actions is no longer null.  Any idea why this would be?
Rogerio
Top achievements
Rank 1
 answered on 23 Mar 2017
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?