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

I have a column chart, defined in MVC as below:-

 

@(Html.Kendo().Chart<Dashboard.Models.BarChartDataItem>(Model)
            .Name((string)ViewBag.ChartName)
             .Title((string)ViewBag.ChartTitle)
             .Theme("bootstrap")
            
 
            .Legend(legend => legend
                .Position(ChartLegendPosition.Top)
                .Visible(false)
            )
 
            .Series(series =>
            {
                series.Column(model => model.BarValue).Name("Actual").Tooltip(t=>t.Visible(true).Template("<div><p>Category:#=dataItem.AxisDescription#</p><p>Contribution: £#=dataItem.DisplayBarValue#</p></div>"));
            })
            .ChartArea(area => area
                .Height(350)
                .Background("transparent")
                )
 
                    .ValueAxis(axis => axis.Numeric()
                .Labels(labels => labels.Format("{0:N2}"))
                .Title((string)ViewBag.Yaxis)
                .AxisCrossingValue(0, int.MinValue)
 
 
 
                .Line(line => line.Visible(false))
            )
 
             .CategoryAxis(axis => axis
               .Labels(false))
            .CategoryAxis(axis => axis
 
                .Categories(model => model.AxisValue)
                .Labels(labels => labels.Rotation(-45).Padding(5))
                .MajorGridLines(lines => lines.Visible(false))
                 .Title((string)ViewBag.Xaxis)
 
 
            )
              
            .Events(e=>e.SeriesClick("seriesClick"))
 
            .Tooltip(tooltip => tooltip
                .Visible(true)
 
                .Format("{0:N2}")
            )
 
)

I then use the SeriesClick event, to implement a data drill-down, which refreshes with the chart with new data (based on the level of drill-down and the value of the clicked column), based on an Ajax call, which gets new JSON data.

 

function PODDrillDown(pod,conscode,specialtycode,directorateCode, period)
       {
 
           var directorate = directorateCode;
           selectedDirectorate = directorateCode;
           selectedspec = specialtycode;
           selectedcons = conscode;
           selectedPOD = pod;
 
           var chartData;
 
           $.ajax({
 
               type: "POST",
               async: true,
               contentType: "application/json;charset=utf-8",
               url: "@Url.Content("~/ChartMaker/GetHRGChapterBarChartData")",
               data: '{"id":2,"periodID":' + period + ',"DirectorateCode":"' + directorate + '","SpecCode":"' + specialtycode + '","ConsCode":"' + conscode + '","POD":"' + pod + '" }',
           dataType: "json",
           success: function (data) {
               if (data.Success == true) {
                   
                   chartData = data.chartData;
 
                   var dataSource = new kendo.data.DataSource({
                       data: chartData
                   });
 
                   var chart = $("#Chart_ID_1").data("kendoChart");
                   chart.dataSource = dataSource;
                   chart.options.title.text = data.ChartTitle;
                   chart.options.valueAxis.title.text = data.YAxisTitle;
                   chart.options.categoryAxis[1].title.text = data.XAxisTitle;
                   chart.dataSource.read();
                   chart.refresh();
 
 
 
 
 
               }
               else {
 
                   alert(data.Error);
               }
 
           },
           error: function () {
               alert("An error has occurred");
           }
 
       });
 
       }

 This works well, however with one particular drill-down , the chart doesn't render properly. The series labels are shown, the value axis seems scaled correctly, but the columns aren't rendered (I've attached an image of the chart). I can't see any issues with the data, all the data calls return data in the same structure, and no errors are thrown.

 

The Ajax call returns the data below :-

 

{"ChartTitle":"Performance for Consultant 4835","XAxisTitle":"Point of Delivery","YAxisTitle":"Contribution (£)","Success":true,"Message":"Data retrieved","Error":null,"chartData":[{"BarValue":-2476080.767381317,"AxisValue":"Other","AxisCode":"OTHER","ExtraValue":4,"AxisDescription":"Other","DisplayBarValue":"-2,476,081"},{"BarValue":-2476080.7673813165,"AxisValue":"Block","AxisCode":"BLOCK","ExtraValue":4,"AxisDescription":"Block","DisplayBarValue":"-2,476,081"}]}

 Is this a bug in the chart, or is it something in the code?

Thanks

Daniel
Telerik team
 answered on 20 Nov 2015
3 answers
149 views

Hello,

I have a Razor build-ed grid which the datasource is WebAPI. The model contains a decimal field.

In Dutch (nl-NL) the separated character for decimal is comma instead of dot.

When setting in JS the Kendo.culture to "nl-NL", and the input contains a comma as ​decimal separated character, the ​created JSON model from Kendo Grid to the WebAPI contains also the comma instead of dot. At server-side the input will bbe set without decimal.

 Example: 34,45 is in the JSON  and gives 3445. 

 If the culture is removed, the JSON contains the dot and all works fine.

Question is, can I force the generated JSON model to handle input always as default culture (dot as decimal separated)?

Daniel
Telerik team
 answered on 20 Nov 2015
1 answer
221 views

This is part of my custom editor:

<div data-container-for="studentID" class="k-edit-field">
    @(Html.Kendo().ComboBoxFor(model => model.StudentID)
          .HtmlAttributes(new { data_bind = "value:StudentID" })
          .DataTextField("FullName")
          .DataValueField("StudentId")
          .Filter(FilterType.Contains)
          .AutoBind(false)
          .Placeholder("Start typing student's name...")
          .Text(Model.StudentID != null ? Model.Title : "")
          .DataSource(source =>
          {
              source.Read(read =>
              {
                  read.Action("GetStudents", "Student").Data("filterStudents");
              })
              .ServerFiltering(true);
          })
          .Events(e =>
          {
            e.Select("onStudentSelected");
          })
    )
</div>
<div data-container-for="title" class="k-edit-field">
    @(Html.HiddenFor(model => model.Title, new { id = "TitleId", data_bind = "value:title" }))
</div>

 

I am trying to set the title with the text from the combobox:

     function onStudentSelected(e) {
        var dataItem = this.dataItem(e.item.index());
        $("#TitleId").val(dataItem.FullName);
    };

  Alert on $("#TitleId").val()  shows that it is set. But when I save the template the value is not passed to the server.

I have also made Title just a standard textboxfor so that I can see that the value is set.

Why is this not persisting to the model?

 

Also, this is my schduler:

@(Html.Kendo().Scheduler<Excent.Apps.Web.Solo.Models.MeetingViewModel>()
    .Name("scheduler")
    .Date(DateTime.Today)
    .StartTime(DateTime.Today.AddHours(8))
    .EndTime(DateTime.Today.AddHours(23).AddMinutes(59))
    .Height(600)
    .Views(views =>
    {
        views.DayView(dw => dw.DateHeaderTemplate("#=kendo.toString(date, 'd')#")).ShowWorkHours(true);
        views.WeekView(weekView => weekView.DateHeaderTemplate("#=kendo.toString(date, 'MM/dd')#").SelectedDateFormat("{0:MM/dd/yyyy} to {1:MM/dd/yyyy}")).ShowWorkHours(true).Selected(true);
        views.MonthView();
        views.AgendaView(aw => aw.Title("Session").SelectedDateFormat("{0:MM/dd/yyyy} to {1:MM/dd/yyyy}"));
    })
        .Editable(editable =>
        {
            editable.TemplateName("CustomEditorTemplate");
        })
    .Timezone("Etc/UTC")
    .EventTemplateId("event-template")
    .DataSource(d => d
        .Model(m =>
        {
            m.Id(f => f.MeetingID);
            m.Field(f => f.Start);
            m.Field(f => f.End);
            m.Field(f => f.IsAllDay);
            m.Field(f => f.Title);
            m.Field(f => f.RecurrenceRule);
            m.Field(f => f.Description);
            m.Field(f => f.StudentID);
            m.Field(f => f.ProcedureCode);
            m.Field(f => f.Color);
            m.RecurrenceId(f => f.RecurrenceID);
        })
        .Events(e => e.Error("error_handler"))
            .Read("Meetings_Read", "ProviderHome")
                .Create("Meetings_Create", "ProviderHome")
                .Destroy("Meetings_Destroy", "ProviderHome")
                .Update("Meetings_Update", "ProviderHome")

    )
)

 

Vladimir Iliev
Telerik team
 answered on 19 Nov 2015
2 answers
826 views

Is there a way to disable drag and drop for tasks in the scheduler?

I want my users only to be able to edit tasks through the edit form.

/Jonas

Jonas
Top achievements
Rank 1
 answered on 19 Nov 2015
1 answer
200 views

I have a very simple listview that I cannot get to show any data. 

 View:

@(Html.Kendo().ListView<PortalContext.Root>()
                    .Name("leafView")
                    .TagName("div")
                    .ClientTemplateId("leafTemplate")                
                            .DataSource(dataSource => {
                                dataSource.Model(model => { model.Id(p => p.RootId);
                                                            model.Field<string>(f => f.ShortName);
                                });
                                dataSource.Read(read => read.Action("Leafs", "Home").Data("branchLevel"));
                            })
                )

 

    <script type="text/x-kendo-tmpl" id="leafTemplate">       
        <div style="height:100px">
            #: ShortName #
        </div> 
    </script>

I have a treeview that refreshes the data onSelect

 

function onSelect(e) {
        if (treeview.dataItem(e.node).IsBranch) {
            branchId = treeview.dataItem(e.node).id;            
            $("#leafView").data("kendoListView").dataSource.read();
        }
    }

    function branchLevel() {
        return {
            branchId: branchId            
        };
    }

I have simplified a few things but my controller looks like this and is basically returning a list of objects.

public ActionResult Leafs([DataSourceRequest]DataSourceRequest request, int? branchId) {

            return Json(ViewModel.Roots.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}

 

Any ideas why this may not be working?

 

Bill

William
Top achievements
Rank 1
 answered on 18 Nov 2015
8 answers
1.5K+ views

I use the Ajax Editing to manage the record in my grid .
I would like call the controller before edit the selected record to check if the record is not lock.
I would like have this process :
   - Click on "Edit" buttom on grid,
   - Call the action controller to check the lock,
       -> If record lock, Abort Edit record,
       -> If record is not lock, Edit record.
 Do you know of a great way to make this process ?
Thanks
I set up a simple grid like this using the Razor syntax:

@(Html.Kendo().Grid<GridCustomPopupTemplate.Models.Person>().Name("persons")
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model => model.Id(m => m.PersonID))
        .Read(read => read.Action("GetPersons", "Home"))
        .Update(up => up.Action("UpdatePerson", "Home"))
    )
    .Columns(columns =>
    {
        columns.Bound(c => c.PersonID).Width(200);
        columns.Bound(c => c.Name);
        columns.Command(cmd => {
            cmd.Edit();
            });
    })
    .Pageable()
    .Sortable()
    .Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("Person"))
)

Boyan Dimitrov
Telerik team
 answered on 18 Nov 2015
16 answers
241 views

Hello, is it possible to have a "Preview Row" (see attached picture) with MVC Grid?

robert

Robert Madrian
Top achievements
Rank 1
Veteran
Iron
 answered on 18 Nov 2015
5 answers
201 views
Hi,
Is it possible to have a grid bound to a signalR datasource and use inline editing?  I've set up my grid to be bound to a signalR datasource and it is successfully bound and I can update the data.  I am unable to get it to work with inline editing and also I cannot get it to update other instances of the grid.  My application is an MVC 5.1 application and I am running on Visual Studio 2012.  The Telerik version I am using is 2014.1.415.  So can you please answer the following:
1. Can the grid have inline editing but still be bound to a signalR datasource ?  If so, can you give an example?
2. Why aren't other instances of my grid updating with the changes?  Any things I can check?  I've followed your example and it seems I'm doing everything the same.

Please help.
Vladimir Iliev
Telerik team
 answered on 18 Nov 2015
5 answers
761 views

I need to stop collapsing a detail row in kendo grid in some cases, but my code is not working:

var detailGrid = $("#grid-details").kendoGrid({
           < ....>
            detailCollapse: function (e) {
                //operator.views.common.CheckDetailsRow(e.detailRow);
                e.preventDefault();
                return false;
            },

<......>
                   }).data("kendoGrid");

Boyan Dimitrov
Telerik team
 answered on 18 Nov 2015
1 answer
1.3K+ views

Hi,

I have a Kendo Grid in which I use Data method in Read.Action to pass parameters to a controller action. The code is:

<% Html.Kendo().Grid<EvaluationsQuestionsEvaluationPillarsGridViewModel>()
            .Name("Pillars")
            .DataSource(dataSource => dataSource
                  .Ajax()
                  .Model(model => model.Id(a => a.EvaluationMasterPillarId))
                  .ServerOperation(true)
                  .Read(read => read.Action("LoadEvaluationsQuestionsEvaluationPillarsGridAjax", "Evaluations")
                                    .Data("onLoadEvaluationsQuestionsEvaluationPillarsGridData"))
             )​
......

        function onLoadEvaluationsQuestionsEvaluationPillarsGridData(e) {
            var evaluationVersionId = $('#evaluationVersionId').val();  // "evaluationVersionId" is set beforehand
            var showDeletedCheckbox = $('#Checkbox1').val();

            return { evaluationVersionId: evaluationVersionId, showDeleted: showDeletedCheckbox }
        }

        public ActionResult LoadEvaluationsQuestionsEvaluationPillarsGridAjax(DataSourceRequest request, string evaluationVersionId, bool showDeleted)
        {
......

But the controller action "LoadEvaluationsQuestionsEvaluationPillarsGridAjax" is not even invoked. I need help on this. Thanks.

 

Dimiter Madjarov
Telerik team
 answered on 18 Nov 2015
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
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Wizard
Security
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
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
DropDownButton
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
+? more
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?