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

Currently I'm trying to access the value of a cell in the grid, but the property is always undefined.

                             @(Html.Kendo().Grid<IA.Models.PatientInfo>()
                              .Name("PatientGrid")
                              .Columns(columns =>
                              {
                                  columns.Bound(c => c.PatientId).Title("Id").Width(50);
                                  columns.Bound(c => c.FullName).Width(200);
                                  columns.Bound(c => c.DOB).Width(140).Title("Date of Birth").Format("{0:dd/MM/yyyy}");
                                  columns.Bound(c => c.MANumber).Width(90);
                                  //columns.Command(command => { command.Destroy(); }).Width(50);
                                  columns.Command(c => c.Custom("Delete").Click("open")).Width(50);
                              })
                              .Filterable()
                              .Sortable()
                              .Selectable()
                              .Pageable(pageable => pageable
                              .PageSizes(true)
                              .ButtonCount(5))
                              //.HtmlAttributes(new { style = "height: 80px" })
                              .Events(ev => ev.DataBound("function(){this.trigger('change')}"))
                              .DataSource(dataSource => dataSource
                                .Ajax()
                                .Destroy(update => update.Action("Destroy", "Provider"))
                                .Read(read => read.Action("Patient_Read", "Provider", new { id = Model.ProviderId }))
                                .PageSize(10)
                                .ServerOperation(false)
                                .Model(model =>
                                {
                                    model.Id(m => m.PatientId);
                                })
                                )

         )

        <script type="text/javascript">

            function open(e) {
                e.preventDefault();

                var row = $(e.currentTarget).closest("tr");

                   var test = row.PatientId;
                    alert(test);
                   }

</script>

 

I've also I've also tried using selectItem() and that doesn't seem to work either.

Viktor Tachev
Telerik team
 answered on 20 Feb 2017
12 answers
2.1K+ views

Hello,

In my JavaScript file I bind to serveral events of the grid like:

var grid = $("#grdStandort").data("kendoGrid");
grid.bind("change", function () {
    loadTabstripData(tabstrip.select().text());
});
tabstrip.bind("show", function () {
    loadTabstripData(tabstrip.select().text());
});

 

this is working fine but now I want to bind to the "read" Event to set my parameters instead of using the .Data() property of the mvc grid (I don't want to set javascript in my grid Definition only want to bind/hook into Event from my external javscript file)

is there a event which I can bind to to set the parameters for the datasource?

 

robert

 

 

Konstantin Dikov
Telerik team
 answered on 20 Feb 2017
1 answer
150 views
I would like to use the Scheduler to schedule classrooms (my resource). My case is a bit different in that I don't have an exact date the classrooms are booked but more a day of week and time slots for the entire year. We are trying to track classroom usage for the year. Any ideas how this can be accomplished using the scheduler?
Vladimir Iliev
Telerik team
 answered on 20 Feb 2017
1 answer
270 views

Hi there,

I have several Kendo charts (bar charts and line charts) with the data series bound to remote and grouped data. I am using the "shared" tooltip to display information on the grouped data together. However, I would like to change the width of the tooltip. I can of course do it globally by changing the Kendo chart tooltip CSS, but this is far from being a good solution because then it doesn't look good on other charts -- please see the enclosed jpg file.

Question: Is it possible to change the CSS definitions (in particular "width") of the chart tooltip separately for every single chart?

Any suggestions are welcome!

-------------------------------------------------------------

An example code below:

@(Html.Kendo().Chart<AmeyQCMVC2.Models.ViewModels.BCIRatiosViewModel>()

        .Name("bciChart_DefectCategoryRatios")
        .DataSource(ds => ds.Read(read => read.Action("GetDefectCategoryBCIRatios", "Report"))
                                              .Group(group => group.Add(model => model.ConditionIndex))
                                              .Sort(sort => sort.Add(model => model.DefectCategory))
        )
        .Theme("Fiori")
        .Title("Component Condition Index per Defect Category")
        .Legend(legend => legend
            .Position(ChartLegendPosition.Right)
        )
        .ChartArea(chartArea => chartArea
            .Margin(15)
        )
        .SeriesDefaults(seriesDefaults =>
            seriesDefaults.Bar()
        )
        .SeriesColors("limegreen", "yellowgreen", "gold", "tomato", "red")
        .Series(series =>
        {
            series.Bar(model => model.Ratio)
                  .Name("");
        })
        .CategoryAxis(axis => axis
            .Categories(model => model.DefectCategory)
            .MajorGridLines(lines => lines.Visible(true))
            .MajorTicks(lines => lines.Visible(true))
        )
        .ValueAxis(axis => axis.Numeric()
            .Title("Percentage of components")
            .Min(0)
            .Max(1)
            .MajorGridLines(lines => lines.Visible(true))
            .AxisCrossingValue(0)
            .Labels(l => l.Format("{0:p0}"))
        )
        .Tooltip(tooltip => tooltip
            .Visible(true)
            .Shared(true)
            .Format("{0:p2}")
            .Color("white")
            .Background("green")
            .Border(1, "green")
        )
        .ToClientTemplate()

)

-------------------------------------------------------------

The viewmodel class is defined as follows:

   public class BCIRatiosViewModel
    {
        public string DefectCategory { get; set; }
        public int ConditionIndex { get; set; }
        public double Ratio { get; set; }
    }

Daniel
Telerik team
 answered on 20 Feb 2017
4 answers
884 views

I have a bar chart that is getting its data from my controller in the form of Json data as shown below:

[
{"SiteId":1,"Hour":9,"Quantity":9.0000,"Value":43.0500,"NumCustomers":5},
{"SiteId":1,"Hour":10,"Quantity":18.0000,"Value":43.6900,"NumCustomers":8},
{"SiteId":1,"Hour":11,"Quantity":7.0000,"Value":22.4200,"NumCustomers":3},
{"SiteId":1,"Hour":14,"Quantity":1.0000,"Value":1.0000,"NumCustomers":1}
{"SiteId":2,"Hour":9,"Quantity":10.0000,"Value":48.0500,"NumCustomers":7},
{"SiteId":2,"Hour":10,"Quantity":20.0000,"Value":83.6900,"NumCustomers":11},
{"SiteId":2,"Hour":11,"Quantity":9.0000,"Value":27.4200,"NumCustomers":5},
{"SiteId":2,"Hour":14,"Quantity":3.0000,"Value":11.0000,"NumCustomers":4}
{"SiteId":3,"Hour":9,"Quantity":7.0000,"Value":33.0500,"NumCustomers":4},
{"SiteId":3,"Hour":10,"Quantity":16.0000,"Value":35.6900,"NumCustomers":7},
{"SiteId":3,"Hour":11,"Quantity":7.0000,"Value":22.4200,"NumCustomers":3},
{"SiteId":3,"Hour":14,"Quantity":2.0000,"Value":5.0000,"NumCustomers":2}
]

 

As you can see, there are multiple sites for the same hours.  The horizontal axis should represent each hour from the data.  Each hour should have a column representing each site, very similar to the 'Column Chart' example on your site.  The code example on the site shows the series data like this:

.Series(series => {
    series.Column(new double[] { 3.907, 7.943, 7.848, 9.284, 9.263, 9.801, 3.890, 8.238, 9.552, 6.855 }).Name("India");
    series.Column(new double[] { 4.743, 7.295, 7.175, 6.376, 8.153, 8.535, 5.247, -7.832, 4.3, 4.3 }).Name("Russian Federation");
    series.Column(new double[] { 0.010, -0.375, 1.161, 0.684, 3.7, 3.269, 1.083, -5.127, 3.690, 2.995 }).Name("Germany");
    series.Column(new double[] { 1.988, 2.733, 3.994, 3.464, 4.001, 3.939, 1.333, -2.245, 4.339, 2.727 }).Name("World");
})

 

My current code that shows the hourly totals for 1 site is listed below, but I'd like this to work for multiple sites as shown the in above collection of Json data. What is the best way to accomplish this?

My current code:

    @(Html.Kendo().Chart<CBECloudBO2.ViewModels.ChartHourlySales>()
            .Name("chartHourlySales")
            .Title("Hourly Sales")
            .DataSource(datasource => datasource
                .Read(read => read.Action("Chart_HourlySales", "Home")))
            .Legend(legend => legend
                .Visible(false))
 
            .ChartArea(chartArea => chartArea
                .Background("transparent"))
 
    .Series(series =>
    {
        series.Column(p => p.Value).Name("Total Sales");
    })
    .CategoryAxis(axis => axis
        .Name("series-axis")
        .Line(line => line.Visible(false))
    )
    .CategoryAxis(axis => axis
        .Name("label-axis")
        .Categories(p => p.Hour)
    )
    .ValueAxis(axis => axis
        .Numeric()
        .AxisCrossingValue(0, int.MinValue)
    )
    .Tooltip(tooltip => tooltip
        .Visible(true)
        .Format("{0}%")
        .Template("#= series.name #: #= value #")
    )
)

 

Thanks,

Shawn

Shawn
Top achievements
Rank 1
 answered on 17 Feb 2017
3 answers
894 views

Apologies for what I hope is a stupid question, given I'm new to MVC & web development.

I have a TreeView with manually added child nodes off the root. I then want to add child nodes to each of those nodes via a foreach loop

The code (that is wrong) is

    @(Html.Kendo().TreeView()
        .Name("treeview")
        .Items(treeview =>
        {
            treeview.Add().Text("Root")
                .Expanded(true)
                .Items(root =>
                {
                    root.Add().Text("Child")
                        .Expanded(true);

                    foreach(var item in Model.Entity.GrandChildData)
                    {
                        {add to Child } item.data;
                    }

 

Thanks

Joana
Telerik team
 answered on 16 Feb 2017
1 answer
284 views

Good day. This must be a very basic thing to do, though I didn't manage to find any information on it.

 

I have a treeview setup like this:

@(
  Html.Kendo().TreeView()
      .Name("treeview")
      .DataTextField("Text")
      .DataSource(dataSource => dataSource.Read(read => read.Action("GetView", "Tree"))
   )

My controller looks like this:

    public class TreeController : Controller
    {
        private readonly IRepository _repository;
 
        public TreeController(IRepository repository)
        {
            _repository = repository;
        }
         
        [HttpGet]
        public JsonResult GetView()
        {
            var items = _repository.GetItems();
            var viewmodel = items.Select(t => new
            {
                id = t.Id,
                Text = t.Text,
                hasChildren = t.HasChildren
            });
            return Json(viewmodel, JsonRequestBehavior.AllowGet);
        }
 
}

That part works just fine.

Now, I would like to add a button that would, say, rename the selected item. So,I know how to get the selected item in the treeview. What I do not know how to implement is the connection viewmodel -> data model. That is, knowing the selected html item I have no idea how to get the model item it coresponds to. That would be solvable if I could add my custom html "model-id" property on every item and pass it back to controller on my button click. Which I have no idea how to implement either.

 

Thank you in advance.

Joana
Telerik team
 answered on 16 Feb 2017
3 answers
301 views

Is there a way to localize the optionlabel text a bit like that:

....

  .OptionLabel(@Localizer["MyLocalizedOptionLabel"].Value)

....

Thanks

Nencho
Telerik team
 answered on 16 Feb 2017
3 answers
400 views

I'm using a grid with a popup editor and use bootstrap layout.

I have done the right styling override but the right margin is not there. Any suggestions.

In the Razor view of the grid

<style>
  .k-edit-form-container {
    width: auto;
    padding:10px;
  }
 
    .k-edit-form-container div {
      box-sizing: border-box;
    }
</style>

In the popup editor

<div class="row">
  <div class="col-md-3">
    <div class="form-group form-group-sm">
      <label asp-for="NAME_RES" class="control-label"></label>
      <div>
        <input asp-for="NAME_RES" class="form-control" />
        <span asp-validation-for="NAME_RES" class="text-danger" />
      </div>
    </div>
  </div>
  <div class="col-md-3">
    <div class="form-group form-group-sm">
      <label asp-for="TYPE_RES" class="control-label"></label>
      <div>
        <select asp-for="TYPE_RES" asp-items=@ViewBag.arType class="form-control"></select>
      </div>
    </div>
  </div>
  <div class="col-md-3">
    <div class="form-group form-group-sm">
      <label asp-for="ROLE_RES" class="control-label"></label>
      <div>
        <select asp-for="ROLE_RES" asp-items=@ViewBag.arRole class="form-control"></select>
      </div>
    </div>
  </div>
  <div class="col-md-3">
    <div class="form-group form-group-sm">
      <label asp-for="IDENTNUMBER_RES" class="control-label"></label>
      <div>
        <input asp-for="IDENTNUMBER_RES" class="form-control" />
        <span asp-validation-for="IDENTNUMBER_RES" class="text-danger" />
      </div>
    </div>
  </div>
</div>

 

Thanks

 

Konstantin Dikov
Telerik team
 answered on 16 Feb 2017
1 answer
184 views

Is there a way to localize field in the popup editor of a grid.
I've try to use the legacy way but it does not work.

I've tried using appropriate resource file

...
@inject IViewLocalizer Localizer
@using Microsoft.AspNetCore.Mvc.Localization
...
        <div>
          <label class="control-label">@Localizer["idsResidents"]</label>
        </div>

Or

...
@inject IViewLocalizer Localizer
@using Microsoft.AspNetCore.Mvc.Localization
...
        <div>
          <label class="control-label">@Localizer["idsResidents"].Value</label>
 </div>
Stefan
Telerik team
 answered on 16 Feb 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?