Telerik Forums
UI for ASP.NET MVC Forum
4 answers
928 views

I have my customized colors for lines and legend. What I need to know is how can I set the color arrangement for the series color in line chart. As I observed it has their own random arrangement for the colors.

 

My sample array of colors: 

var myColors = ["lightblue", "pink", "yellow", "green", "orange", "red", "teal"];

whenever I load an dataSeries the color will randomly select an color.

I need to set my color per key, for example:

Test 1 = "lightblue", Test 2 = "pink", Test 3 = "yellow"....

 

In the series color defaults will generate colors randomly not based on my customized colors.

Question, is what I need to do to set my customized array of colors?

How can I accomplish this?

 

sample code:

$("#chart").kendoChart({
                title: { text: "MyChart" },
                theme: "Metro",
                dataSource: dataSeries,
                seriesColors: ["lightblue", "pink", "yellow", "green", "orange", "red", "teal"],               
                //seriesColors: myColor,
                series: [{
                    type: "line",
                    field: "value()",
                    categoryField: "Date",
                    name: "#= group.value #",
                    color: "red",
                    markers: {
                        type: 'circle',
                        visible: true,
                        background: 'black',
                        size: 5
                    }
                }],

 

 

Hope to hear from you. I need this to be done as my project is urgent.

Thanks!

 

Regards,

Jerson

Stefan
Telerik team
 answered on 10 Jul 2017
8 answers
168 views

I am using the Example http://demos.telerik.com/aspnet-mvc/grid/hierarchy

 

The Main part of the Grid loads fine but the other one appears to give me a javascript error saying the woid is not defined. Looking at the developer controls in Chrome it also looks like the woid is not being injected.  So I am trying to understand the hashtags and these variables #=woid#   I am looking at .Name("grid_#=woid#") and this is a copy of the demo but using my data. I don't see where the woid data is coming from (on the example this would be the EmployeeID)  some research says that is is related to the CSS, but ther source code does not have any clues to what and how this is used.  

 

@model IEnumerable<GISPortal.GRIDPRINTS>
 
@(Html.Kendo().Grid<GISPortal.GRIDPRINTWO>()
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(e => e.WOID).Width(110);
            columns.Bound(e => e.REQUESTDATE).Width(110);
            columns.Bound(e => e.NOTIFICATIONTYPE).Width(110);
            columns.Bound(e => e.COMPLETED).Width(110);
            columns.Bound(e => e.ERRORS);
 
        })
        .Sortable()
        .Pageable()
        .Scrollable()
        .ClientDetailTemplateId("template")
        .HtmlAttributes(new { style = "height:600px;" })
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(6)
            .Read(read => read.Action("GRIDPRINTWO_Read", "GridPrint"))
        )
        .Events(events => events.DataBound("dataBound"))
)
 
<script id="template" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<GISPortal.GRIDPRINTS>()
            .Name("grid_#=woid#") // template expression, to be evaluated in the master context
            .Columns(columns =>
            {
                columns.Bound(o => o.MAPNAME).Width(110);
                columns.Bound(o => o.SCALE).Width(110);
                columns.Bound(o => o.PAGENUMBER);     //.ClientTemplate("\\#= ShipAddress \\#"); // escaped template expression, to be evaluated in the child/detail context
                columns.Bound(o => o.STATUS).Width(300);
                columns.Bound(o => o.ERRORS).Width(300);
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(10)
                                .Read(read => read.Action("GRIDPRINTS_Read", "GridPrint", new { woid = "#=woid#" }))
            )
            .Pageable()
            .Sortable()
            .ToClientTemplate()
    )
</script>
<script>
    function dataBound() {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
    }
</script>
Viktor Tachev
Telerik team
 answered on 10 Jul 2017
1 answer
567 views

Hi there,

 

I'm creating a custom datasource

01.@(Html.Kendo().Grid<Foo>()
02.    .Name("grid")
03.    .AutoBind(false)
04.    .DataSource(dataSource => dataSource
05.       .Custom()
06.       .Batch(true)
07.       .Schema(s =>
08.         s.Model(model =>
09.         {
10.            model.Id(p => p.ID);
11.            model.Field(x => x.ID).DefaultValue(0);
12.         })
13.       )
14.       .Transport(new
15.       {
16.          read = new Kendo.Mvc.ClientHandlerDescriptor() { HandlerName = "customRead" },
17.          create = new Kendo.Mvc.ClientHandlerDescriptor() { HandlerName = "customCreate" },
18.          update = new Kendo.Mvc.ClientHandlerDescriptor() { HandlerName = "customUpdate" },
19.          destroy = new Kendo.Mvc.ClientHandlerDescriptor() { HandlerName = "customDestroy" },
20.       })
21.    )
22.)

 

I need in runtime to change all the transport's handlers (in JavaScript).

I've read the documentation and some posts in the forum but I can't make it work. The last thing I tried was this

 

01.function anotherDestroy(e) {
02.    console.log("calling anotherDestroy()");
03.}
04. 
05.let ds =
06.    $("#grid")
07.        .data("kendoGrid")
08.        .dataSource;
09. 
10.ds.transport.options.destroy = anotherDestroy;

 

Can someone please tell me what I'm doing wrong?

Thank you.

Stefan
Telerik team
 answered on 10 Jul 2017
4 answers
441 views

Hi,

How to set minimum and maximum date range in Line Chart categoryAxis?

Please see min and max in sample code:

 

},
                categoryAxis: {                    
                    min: new Date("6/7/17"),
                    max: new Date("7/7/17"),
                    //type: "date",
                    baseUnit: "days",
                    majorGridLines: {
                        visible: true
                    },
                    labels: {
                        rotation: 40,
                        padding: { right: 10 },
                        dateFormats: {
                            days: "M/d/yy"
                        },
                        step: step
                    }
                }
            });

 

I set it to static, but even if i set it thru var dynamically, same error happens. Please see attached file.

 

 

Daniel
Telerik team
 answered on 10 Jul 2017
2 answers
714 views

Hello,

I need to display a chart binded dynamically with multiple series of the same object type.

I managed to do that using the following chart parameters :

dataSource: {
    data: data,
    group: {
        field: "group"
    }
}

where my data looks like this (this is only an example, data is actually:

var data = [{
    group: "First",
    category: 1,
    value: 100
},
{
    group: "First",
    category: 2,
    value: 200
},
{
    group: "Second",
    category: 1,
    value: 200
},
{
    group: "Second",
    category: 2,
    value: 400
}];

 

However, this structure doesn't suit my other needs (such as displaying a table with one row per group), so I'd like to know if it's possible to display the same chart using data as following :

var data = [{
    group: "First",
    values: [{
        category: 1,
        value: 100
    },
    {
        category: 2,
        value: 200
    }]
},
{
    group: "Second",
    values: [{
        category: 1,
        value: 200
    },
    {
        category: 2,
        value: 400
    }]
}];

 

How can I do that ?

Thanks a lot for your help.

Best regards

Daniel
Telerik team
 answered on 10 Jul 2017
3 answers
544 views
Hi, I was wondering how I could programmatically do this in javascript as I want to make a re-usable javascript function for initializing common grid settings:

.Events(events => events.Change("kendoGridWithCheckboxColumnSelectionOnChange"))
Milena
Telerik team
 answered on 07 Jul 2017
1 answer
2.2K+ views

I have the following textbox defined...

@(Html.Kendo().TextBox().Name("textbox_DataSourceName").HtmlAttributes(new { style = "width:500px;" }))

 

When it's rendered the width does not change, no matter what size I specify.

Stefan
Telerik team
 answered on 07 Jul 2017
5 answers
1.4K+ views
When I change an amount, tick the checkbox etc, it triggers some javascript, which includes some code to set another field on the dataItem, so `dataItem.Set ("Amount", 0);`

I can set it using `dataItem.Amount = 0;` , but then I also need to update the contents of the <td> cell.  When I do set I obviously don't want the dirty flag clearing from other cells, as I haven't clicked 'Save changes' yet, so they are still 'dirty'.

I can't find any documentation on the .set method. It's as though it is firing other events off.

Any advice would be appreciated.

@(Html.Kendo().Grid<OurViewModel>()
.Name("Grid")
.DataSource(dataSource => dataSource
    .Ajax()
    .Model(model =>
    {
        model.Id(a => a.ID);
        model.Field(a => a.Reference).Editable(false);
        model.Field(a => a.Narrative).Editable(false);
        model.Field(a => a.Include).Editable(true);
        model.Field(a => a.Amount).Editable(true);
    })
    .Batch(true)
    .Read(read => read.Action("_Read", "Home"))
    .Update(update => update.Action("_Update", "Home"))
    .ServerOperation(false)
    .Events(events =>
    {
        events.Change("onDataSourceChange");
    })
)
.Columns(columns =>
{
    columns.Bound(a => a.Reference).Title("Reference");
    columns.Bound(a => a.Narrative).Title("Narrative");
    columns.Template(@<text></text>).Title("Include?")
        .ClientTemplate("<input type='checkbox' #= Include ? checked='checked': '' # onclick='updateAmount(this, \"#= ID#\")' />");
    columns.Bound(a => a.Amount).Title("Amount");
})
    .Events(events =>
    {
        events.Save("onSave");
        events.SaveChanges("onSaveChanges");
    })
.ToolBar(toolbar =>
{
    toolbar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
)   

and the JS.

function updateAmount(cb, ourID) {
            var checked = $(cb).is(':checked');
            var grid = $('#Grid').data().kendoGrid;
            var dataItem = grid.dataSource.get(ourID);
            dataItem.set("Include", checked);
            if (checked) {
                dataItem.set("Amount", dataItem.get("OriginalAmount"));
            } else {
                dataItem.set("Amount", 0);
            }
       }
Samra
Top achievements
Rank 1
 answered on 07 Jul 2017
5 answers
294 views

I'm currently using a template in my scheduler, and have a button in it that depends on the id of a particular event. This works fine for single events, but I'm running into issues with recurring events. For recurring events, the id is passed to the first instance of the event shown in the scheduler, but 0 is passed to subsequent instances. This seems strange to me since all other fields (like "title") are passed to every instance. This breaks my button, as it relies on that id.

I've attached a screen shot showing the behavior. You can see that, for the recurring events, the title is displayed for every instance, but the id becomes 0 after the first instance.

Can someone explain this behavior to me? Is there a way I can get the event id to be passed to every instance of a recurring event to be used by my template?

 

Ivan Danchev
Telerik team
 answered on 06 Jul 2017
4 answers
280 views

Hello,

How do you get/read the value of the NumericTextBox right after you copy and paste the value into the box? 

 

Thanks!

Liem
Top achievements
Rank 1
 answered on 06 Jul 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?