Telerik Forums
Kendo UI for jQuery Forum
3 answers
206 views
I created a site that has 3 tabs.  In one of the tabs there are some very simple anchor tags.  E.g. <a href="www.telerik.com">Telerik Link</a> 

The issue is that some people in the company are complaining that the links dont work on their IPads.  

Any suggestions?
Angela
Top achievements
Rank 1
 answered on 11 Dec 2012
1 answer
135 views
I can tell it's returning the right message, but it never displays the message.  What am I missing?

DateValidator:
using System;
using System.ComponentModel.DataAnnotations;
 
namespace PosPayAndBankRec.Models.Validators
{
    public class Date
    {
        public enum ValidationType
        {
            RangeValidation,
            Compare
        }
  
        public class DateValidationAttribute : ValidationAttribute
        {
            private ValidationType _validationType;
            private DateTime? _fromDate;
            private DateTime _toDate;
            private string _defaultErrorMessage;
            private string _propertyNameToCompare;
 
            public DateValidationAttribute(string message, string compareWith = "")
            {
                _propertyNameToCompare = compareWith;
                _defaultErrorMessage = message;
            }
            protected override ValidationResult IsValid(object value, ValidationContext validationContext)
            {
                var baseProperyInfo = validationContext.ObjectType.GetProperty(_propertyNameToCompare);
                DateTime startDate;
                bool NotValid = false;
 
                if (baseProperyInfo.GetValue(validationContext.ObjectInstance, null) is DateTime)
                {
                    startDate = (DateTime)baseProperyInfo.GetValue(validationContext.ObjectInstance, null);
 
                    if (value != null)
                    {
                        DateTime thisDate = (DateTime)value;
 
                        if (thisDate <= startDate)
                        {
                            NotValid = true;
                        }
                    }
                    else if (value == null)
                    {
                        //From date as a value but not the to date
                        NotValid = false;
                    }
                }
                else
                {
                    //To  date not a date and we have a from date
                    if (value != null)
                    {
                        NotValid = true;
                    }
                }
 
                //return validation result
                if (NotValid == false)
                {
                    return null;
                }
                else if (NotValid == true)
                {
                    string message = string.Format(_defaultErrorMessage, validationContext.DisplayName);//, displayAttr.Name);
                    return new ValidationResult(message);
                }
                return null;
            }
        }
    }
}


TreasuryModel:
[Date.DateValidation("Deactivation Date should be greater than the Activation Date.", compareWith: "brActivationDate")]
public Nullable<System.DateTime> brDeactivationDate { get; set; }


TreasuryPopupTemplate:
                <td>
                    @Html.EditorFor(model => model.brActivationDate)
                    @Html.ValidationMessageFor(model => model.brActivationDate)
            </td>
            <td>
                    @Html.EditorFor(model => model.brDeactivationDate)
                    @Html.ValidationMessageFor(model => model.brDeactivationDate)
            </td>
Petur Subev
Telerik team
 answered on 11 Dec 2012
1 answer
717 views
Hello,

I'm using Kendo for ASP.NET MVC but I have a grid defined using JavaScript syntax, however, I am struggling with defining a custom validation rule for my model that the grid is bound to.

Updated: After some research I found out my syntax issue with the rule definitions inside a grid, however, now I'm struggling with one of my validation rules. Basically I have 2 IP addresses that can be edited one row at a time. I have 2 custom validation rules defined, one that verifies that the IP is valid and the second one verifies that the two IP's are a valid range. The logic in this sample doesn't do as extensive validation at the moment. All I do is convert the dot notation of the IP's into their Int64 value and make sure that StartIP <= EndIP. The problem I'm facing now is that the second validation rule never works for me and I am unsure how I can even debug it. I assume due to the way the validation rules are evaluated, console.log or writing output to a dummy console div on the page does not work so I can't verify the values that are coming in.

Any help would be greatly appreciated.

var companyId = parseInt(@ViewBag.CompanyID);
 
var dataSource = new kendo.data.DataSource({
    type: 'aspnetmvc-ajax',
    transport: {                   
        create: {
            url: '@Url.Action("CreateHost", "Security", new { area = "" })',
            dataType: 'json'
        },
        read: {
            url: '@Url.Action("GetHosts", "Security", new { area = "" })',     
            data: {
                companyId: companyId
            },
            dataType: 'json',
            type: 'GET'
        },
        update: {
            url: '@Url.Action("UpdateHost", "Security", new { area = "" })',
            dataType: 'json'
        },
        destroy: {
            url: '@Url.Action("DeleteHost", "Security", new { area = "" })',
            dataType: 'json'
        }
    },
    schema: {
        model: {
            id: 'HostID',
            fields: {
                HostID: {
                    type: 'number',
                    editable: false
                },
                StartIP: {
                    type: 'string',
                    editable: true,
                    validation: {
                        required: {
                            message: 'Start IP is required'
                        },
                        validIP: function (input1) {
                            input1.attr('data-validIP-msg', 'Invalid IP address');
                            return ipRegEx.test(input1.val());
                        },
                        validIPRange: function (input1) {                      
                            if (input1.is('input[id=StartIP]')) {
                                input1.attr('data-validIPRange-msg', 'Start IP must be smaller than End IP');
 
                                var input2 = input1.closest('input[id=EndIP]');
 
                                var d1 = input1.val().split('.');
                                var d2 = input2.val().split('.');
 
                                var n1 = ((((((+d1[0]) * 256) + (+d1[1])) * 256) + (+d1[2])) * 256) + (+d1[3]);
                                var n2 = ((((((+d2[0]) * 256) + (+d2[1])) * 256) + (+d2[2])) * 256) + (+d2[3]);
 
                                return n1 >= n2;
                            }
                            return true;
                        }
                    }
                },
                EndIP: {
                    type: 'string',
                    editable: true,
                    validation: {
                        required: {
                            message: 'End IP is required'
                        },
                        validIP: function (input2) {
                            input2.attr('data-validIP-msg', 'Invalid IP address');
                            return ipRegEx.test(input2.val());
                        },
                        validIPRange: function (input2) {                                                          
                            if (input2.is('input[id=EndIP]')) {
                                input2.attr('data-validIPRange-msg', 'End IP must be greater than Start IP');
 
                                var input1 = input2.closest('input[id=StartIP]');
 
                                var d1 = input1.val().split('.');
                                var d2 = input2.val().split('.');
 
                                var n1 = ((((((+d1[0]) * 256) + (+d1[1])) * 256) + (+d1[2])) * 256) + (+d1[3]);
                                var n2 = ((((((+d2[0]) * 256) + (+d2[1])) * 256) + (+d2[2])) * 256) + (+d2[3]);
 
                                return n1 >= n2;
                            }
                            return true;
                        }
                    }
                },
                StatusID: {
                    type: 'number',
                    editable: false,
                    defaultValue: 3
                },
                CreatedOn: {
                    type: 'date',
                    editable: false,
                    defaultValue: new Date()
                }
            }
        },
        data: 'Data',
        total: 'Total'
    },
    batch: false,
    pageSize: 30,
    serverPaging: true,
    serverFiltering: true,
    serverSorting: true
});
 
var grid = $('#HostsGrid').kendoGrid({
    dataSource: dataSource,
    toolbar: ['create'],
    columns: [
        { field: 'StatusID', title: 'Status', editable: false, filterable: false, sortable: true, template: '#= formatStatus(StatusID, true, "html") #', width: 97 },
        { field: 'StartIP', title: 'Start IP', editable: true, filterable: false, sortable: false },
        { field: 'EndIP', title: 'End IP', editable: true, filterable: false, sortable: false },               
        { field: 'CreatedOn', title: 'Added On', editable: false, filterable: true, sortable: true, format: '{0:MM/dd/yyyy hh:mm tt}', width: 150 },
        { command: ["edit", "destroy"], title: ' ', width: 200 },             
    ],
    columnMenu: true,
    editable: 'inline',
    height: 250,
    filterable: true,
    pageable: {
        // Disable traditional paging, we are using virtual scrolling (which does the paging)
        previousNext: false,
        numeric: false,
 
        // Show the refresh button in the pager
        refresh: true
    },
    scrollable: {
        virtual: true
    },
    sortable: true     
});
Vesselin Obreshkov
Top achievements
Rank 2
 answered on 11 Dec 2012
1 answer
82 views



the image i have attached,on click of the combo box,need some text box just like gmail search option
Georgi Krustev
Telerik team
 answered on 11 Dec 2012
1 answer
520 views
Hi,

I am trying to generate a Pie Chart with Multiple Series, a side by side comparison to be exact, but I am having issues.  When having two series on the Pie Chart it puts one pie on top of the other.  It is retrieving the data properly, it just isn't that helpful one on top of the other :)

Below is my JavaScript that generates my report.

Note: This will not work independently because kendoDataSource and  chartChangesTitle are defined elsewhere, but hopefully this is enough information to help.

Thanks!
$("#chartDetails").kendoChart({
            chartArea: {
                margin: 0,
                height: 550
            },
            theme: $(document).data("kendoSkin") || "BlueOpal",
            dataSource: kendoDataSource,
            title: {
                text: chartChangesTitle
            },
            legend: {
                visible: false,
                position: "bottom"
            },
            seriesDefaults: {
                labels: {
                    template: "#= kendo.format('{0} - {1:P}', category, percentage)#",
                    visible: true
                },
                stacked: false
            },
            series:[
                {
                    type: "pie",
                    field: "InitialVolume",
                    categoryField: "AttributeValue",
                    name: "Initial"
                },
                {
                    type: "pie",
                    field: "ProposedVolume",
                    categoryField: "AttributeValue",
                    name: "Proposed"
                }
            ],
 
            categoryAxis: {
                field: "AttributeValue"
            },
            tooltip: {
                visible: true,
                template: "#= kendo.format('{0} - {1:P}', category, percentage)#"
            }
        });
Hristo Germanov
Telerik team
 answered on 11 Dec 2012
2 answers
274 views
I have a question of the recommended way to handle errors from the Kendo Grid when using an OData data source.

I understand that using a custom data source, you can use the schema.errors property to define the property in the data source that contains errors.

Does OData have a corresponding concept?  If not - is there a recommended way to handle errors from OData data sources?

Also - what does the grid do with any errors it receives?  Log them using the kendo log API or something else?

thanks,
Adam
Adam
Top achievements
Rank 1
 answered on 11 Dec 2012
2 answers
126 views
In the ASP.NET Ajax RadGrid control, there is a client select column that enables a row to be selected using a checkbox. We've been trying to mesh the row select features of the Kendo grid with a column of check boxes and it has proved to be very difficult since we can't prevent the onchange event from firing. Do you happen to have any suggestions on how to do this?
Chris
Top achievements
Rank 1
 answered on 11 Dec 2012
1 answer
2.8K+ views
Hi,

I'm currently playing with aspnet webforms with jquery (via kendo mobile). I have the following setup below. In the aspx page,
I need to call the 'Book' method in a 'controller' on a button click. I'm guessing I will need to use $.ajax? or is there another way via kendo dataSource? any sample code of the 'ajax' call would really help as i'm at the earliest stages of learning this stuff,

Kind regards.

//shift.aspx
function showShiftDetailView(e) {
        var view = e.view;

        sds.fetch(function () {
            item = sds.get(view.params.id);
            view.scrollerContent.html(shiftItemDetailTemplate(item));
            kendo.mobile.init(view.content);
        });
       
       $('<a data-role="button" id="bookbutton">Book</a>').insertBefore('#shiftdetaillistview');
       $('#bookbutton').click(function () {
                // **** 1. call book function
                BookShift(item.id)        
            });
        }
}

function BookShift(id) {
   *** 2. call 'Book' method with parameter here and get response**
  $.ajax ?
}

//shiftcontroller.cs
// CONTROLLER
 public class ShiftController : ApiController
    {
        private Data.Shift _context = new Data.Shift();
        HttpRequest _request = HttpContext.Current.Request;

        // WebAPI will respond to an HTTP GET with this method
        public Model.Response Get()
        {
            // the the take and skip parameters off of the incoming request
            int take = _request["take"] == null ? 10 : int.Parse(_request["take"]);
            int skip = _request["skip"] == null ? 0 : int.Parse(_request["skip"]);

            var entries = (from System.Data.DataRow r in _context.GetData().Rows
                           select new Model.Shift(r)).Skip(skip).Take(take).ToArray();

            return new Model.Response(entries, _context.GetData().Rows.Count);
        }

// **** 3.  I want to call this from a button click *** //
        public Model.Response Book(string tempShiftPlanid)
        {
            IPoint.Shifts.Shift shift = new IPoint.Shifts.Shift();
            shift.id =  id;
            return new Model.Response(shift.BookShift());
        }
    }

// Response.cs
public class Response
{
        public string DBData { get; set; }

        public Response(string dbdata)
        {
            this.DBData =dbdata;
        }
}
Petyo
Telerik team
 answered on 11 Dec 2012
1 answer
179 views
HI All

How to achieve the alert or message box  function of kendo

Devolopment Team.
Iliana Dyankova
Telerik team
 answered on 11 Dec 2012
2 answers
148 views
This isn't a big issue but the pager controls should be hidden when total results is less than the pageSize.
I have attached screens of the vanilla and my modification to better visualize the improvements.
Marcin Butlak
Top achievements
Rank 2
 answered on 11 Dec 2012
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
DatePicker
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Application
Map
Drag and Drop
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
Filter
SPA
Drawing API
Drawer (Mobile)
Globalization
LinearGauge
Sortable
ModalView
Hierarchical Data Source
Button
FileManager
MaskedTextBox
View
Form
NavBar
Notification
Switch (Mobile)
SplitView
ListBox
DropDownTree
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
ColorPicker
Pager
Styling
MultiColumnComboBox
Chat
DateRangePicker
Dialog
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Effects
Accessibility
PivotGridV2
ScrollView
BulletChart
Licensing
QRCode
ResponsivePanel
Switch
Wizard
CheckBoxGroup
TextArea
Barcode
Breadcrumb
Collapsible
Localization
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
TimePicker
BottomNavigation
Ripple
SkeletonContainer
Avatar
Circular ProgressBar
FlatColorPicker
SplitButton
Signature
Chip
ChipList
VS Code Extension
AIPrompt
PropertyGrid
Sankey
Chart Wizard
OTP Input
SpeechToTextButton
InlineAIPrompt
StockChart
ContextMenu
DateTimePicker
RadialGauge
ArcGauge
AICodingAssistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?