Telerik Forums
Kendo UI for jQuery Forum
3 answers
277 views
Greetings,

We are having difficulty getting the kendoui datepicker working under what we consider to be some fairly common use cases.   

Example 1:

Easily visible via the sample: http://demos.telerik.com/kendo-ui/web/datepicker/events.html

Consider a requirement where this field is optional, but if filled in must parse out and be a legitimate date.   Currently if I enter "asdfasdf" or even something as innocent as "25/5/2012" (consider a non-us user who is used to dd/mm/yyyy) then the changed event is never fired.   I thus have no opportunity to warn the user that the date they have entered is invalid.

Example 2:

Let's say I set a maximum date of todays date on the control.   Now when I click the calendar, it properly disallows selection of a future date.   However, what I can do is go in and type in any date I want.   If a date in the future is inputted, the control determines null as the value and again, since the initial value was null as well the change event is never raised, and there is no way to provide UI validation in an MVVM scenario.


Desired behavior
The easiest change here probably would be to simply give us an option to have the textbox get cleared out when the control loses focus if the date is null that way at least what the user sees in the control will match what the control is reporting as its' value.

A good example of this is the multiselect box.  If you type gyberish into it and tab out, it wipes out the invalid value.  Why does the datepicker need to retain its invalid data?

Otherwise, we need some way to be notified via event not only when the underlying date value has changed, but also when the text changes if we are to jump through these hoops ourselves (manually parse the text according to configured formats, clear out the value if needed, etc).
















Atlas
Top achievements
Rank 1
 answered on 08 Nov 2014
1 answer
343 views
Hi,
I need setup custom validation on grid fields dynamically,
because code processes many forms from database and
I know a set of columns only at runtime. I took Telerik's example
for checking and changed something a little bit (see index.zip) and
got the next results.
When I set name of the field statically ("ProductName") everything is OK.
When I try use in string concatenation gridColumns[i].field I get in console
message that variable is not defined. When I set fieldName = gridColumns[i].field
I don't  receive any message, I see custom validation on the column
(see kendoui-grid-custom-validator.jpg), but custom validation doesn't work.
Standard validation works (required: true).
Is it possible to use variables from closure in javascript? Or there is
another way to define it?
Ilya
Top achievements
Rank 1
 answered on 07 Nov 2014
4 answers
150 views
I'm seeing conflicting information regarding support for the HTML5 History API in Kendo. I can't find any mention of it in the docs, but I do see a comment about how history is implemented in SPA via the Router using page fragments (#stuff). I do not want to use page fragments. Instead, I want to use the HTML5 History API.
I submitted a feature request for this, but it was declined because it is apparently already supported:
http://feedback.kendoui.com/forums/127393-kendo-ui-feedback/suggestions/4183941-support-html5-history-api

Where is it supported and is there any documentation I can look at to see how to use it?
Josh
Top achievements
Rank 1
 answered on 07 Nov 2014
1 answer
201 views
Hi there, 

I have a grid with the clientRowTemplate and the ability to reorder columns. I'm saving the reordered columns state and retrieving on the next user login, when I call the grid.reorderColumn() on$(window).ready(), the columns are getting reordered but the rows are not. If i removethe clientrowtemplate, the rows are getting reordered too. Is there a way to reorder the rows along with the columns keeping the clientRowTemlpate on the grid? 
@(Html.Kendo().Grid<JobRequest>()
    .Name("Jobs")
    .Columns(columns =>
    {
        columns.Bound(m => m.Job_Name)
            .Width(110);
        columns.ForeignKey(m => m.TimeFrame, (IEnumerable<TimeFrameType>)Model.timeFrames, "TimeDiff", "TimeDiffName")
            .Filterable(filter => filter
                .Extra(false)
                .Operators(operators => operators
                    .ForNumber(str => str.Clear()
                        .IsLessThan("Less Than")
                    )
                    .ForString(str => str.Clear()
                        .IsEqualTo("Less Than")
                    ))
             )
            .Width(110);
        columns.Bound(m => m.Started)
            .Width(75).Filterable(false).
            Format("{0:MM/dd hh:mm}");
        columns.Bound(m => m.Run_Time)
            .Width(75)
            .Title("Run Time").Filterable(false);
        columns.Bound(m => m.Last_Update)
            .Width(75)
            .Format("{0:MM/dd hh:mm}").Filterable(false);
        columns.Bound(m => m.Job_Priority)
            .Width(40);
        columns.Bound(m => m.Job_ID)
            .ClientTemplate("<a href='javascript:showJobSetWindow(#=Job_ID#)'>#=Job_ID#</a>")
            .Width(90);
        columns.ForeignKey(m => m.Job_Class, (System.Collections.IEnumerable)ViewData["jobClass"], "Value", "Text")
            .Width(85);
        columns.Bound(m => m.WF_Name)
            .Width(200);
        columns.Bound(m => m.User_ID)
            .Width(75);
        columns.Bound(m => m.Division)
            .Width(75);
        columns.Bound(m => m.Cust_Ref)
            .Width(85);
        columns.ForeignKey(m => m.JobStatus, (System.Collections.IEnumerable)ViewData["jobStatus"], "Value", "Text")
            .Width(85);
        columns.ForeignKey(m => m.StepStatus, (System.Collections.IEnumerable)ViewData["stepStatus"], "Value", "Text")
            .Width(85);
        columns.Bound(m => m.Task_Name)
            .Filterable(false)
            .Width(270);
        columns.Bound(m => m.User_System)
            .Width(100);
        columns.ForeignKey(m => m.JobStatus, (System.Collections.IEnumerable)ViewData["jobStatus"], "Value", "Text")
           .Width(85)
           .Title("eReport");
    })
    .Events(events => events
        .FilterMenuInit("filterMenuInit").ColumnReorder("colReorder")
    )
    .ClientRowTemplate(
        "<tr class='clr#:JobStatus#'>" +
        "<td>#: Job_Name #</td>" +
        "<td>#: TimeFrame #</td>" +
        "<td>#: kendo.toString(Started, 'MM/dd hh:mm') #</td>" +
        "<td>#: Run_Time #</td>" +
        "<td>#: kendo.toString(Last_Update, 'MM/dd hh:mm') #</td>" +
        "<td>#: Job_Priority #</td>" +
        "<td><a href='javascript:showJobSetWindow(#=Job_ID#)'>#=Job_ID#</a></td>" +
        "<td>#: Job_Class #</td>" +
        "<td>#: WF_Name #</td>" +
        "<td>#: User_ID #</td>" +
        "<td>#: Division #</td>" +
        "<td>#: Cust_Ref #</td>" +
        "<td># if(JobStatus == \"ERRORED\"){#<a href='javascript:showJobLogWindow(#=Job_ID#)'>#=JobStatus#</a></td>#}else{##=JobStatus##} #</td>" +
        "<td>#: StepStatus #</td>" +
        "<td>#: Task_Name #</td>" +
        "<td>#: User_System #</td>" +
        "<td># if(JobStatus==\"COMPLETED\"){#<a href='javascript:showeReportsWindow(#=Job_ID#)'>View</a></td>#}else{}#</td>"+
         "</tr>"
    )
    .Pageable()
    .Sortable()
    .Scrollable(a => a.Height("auto"))
    .Resizable(resize => resize.Columns(true))
    .Reorderable(reorder => reorder.Columns(true))
    .Filterable(filterable => filterable
        .Enabled(true)
        .Extra(true)
        .Messages(m => m.IsTrue("Yes"))
        .Messages(m => m.IsFalse("No"))
        .Operators(operators => operators
            .ForString(str => str
                .Clear()
                .Contains("Contains")
                .DoesNotContain("Not Contains")
                .StartsWith("Starts with")
                .EndsWith("Ends with")
            )
        )
    )
    .DataSource(dataSource => dataSource
        .Ajax()
        .ServerOperation(true)
        .PageSize(20)
        .Events(e => e.RequestEnd("onReqEnd"))
        .Read(read => read.Action("ReadData", "Home")
        .Data("ReadData"))
    )
 
)

This is the function i'm calling on Window.ready
function reorderCheck() {
       var grid = $("#Jobs").data("kendoGrid");
       var cols = grid.columns;
       //var cs = JSON.parse($.cookie("colState"));
       var cs;
       var userSetting = '@Model.UserSetting'.replace('columns=', '').replace(/"/g, '"');
       if (userSetting != "")
           cs= JSON.parse(userSetting);
       var curColumns=grid.columns;
       if (cs) {
           if (cs.length > 0) {
               for (var i = 0; i < cs.length; i++) {
                  var curColState = cs[i];
               
                   $.map(grid.columns, function (elementOfArray, indexInArray) {
                       if (elementOfArray.field == curColState.field) {
                           grid.reorderColumn(i, grid.columns[indexInArray]);
                            
                       }
                   });
                  
               }
           }
       }
   }



Thanks!
Phani
Dimo
Telerik team
 answered on 07 Nov 2014
6 answers
2.4K+ views
Is there a way to pass additional data the button's click event? I need to pass information from the data item that the button is on (ListView template) to the function handling the click event.

Thanks!
Dimo
Telerik team
 answered on 07 Nov 2014
2 answers
207 views
Hello,

Is there a way to define something like an AngularJs ng-click handler  for your toolbar buttons, so that you don't have to manually call $apply?

As an example, here is what I currently do:
$scope.paymentToolbarOptions = {
    items: [{
    type: "button", id: "manualIr", text: "Manual IR", overflow: "always"
    }...],
    click: function (e) {
        if (e.id === "manualIr") {
         $scope.$apply(function() { $scope.payManualIr(); });
        }
  }
};

Thanks,
Lars


Alexander Valchev
Telerik team
 answered on 07 Nov 2014
2 answers
447 views
Hi,

I prepared solution for save Kendo grid state into database and load it. I have problem, because if I click Load state everything was loading correctly but toolbar with standard create command disappear. Please help I don't know what I'm doing wrong.

This is code for save/load state:

function save_state() {
        var grid = $("#Projects").data("kendoGrid");

        var dataSource = grid.dataSource;

        var state = {
            columns: grid.columns,
            toolbar: grid.options.toolbar,

            page: dataSource.page(),
            pageSize: dataSource.pageSize(),
            sort: dataSource.sort(),
            filter: dataSource.filter(),
            group: dataSource.group()
        };

        $.ajax({
            url: "/Projects/Save",
            data: {
                data: JSON.stringify(state)
            }
        });
    }

    function load_state() {
        var grid = $("#Projects").data("kendoGrid");

        var dataSource = grid.dataSource;

        $.ajax({
            url: "/Projects/Load",
            success: function (state) {

                var loaded_state = JSON.parse(state);

                var options = grid.options;

                options.columns = loaded_state.columns;

                options.dataSource.page = loaded_state.page;
                options.dataSource.pageSize = loaded_state.pageSize;
                options.dataSource.sort = loaded_state.sort;
                options.dataSource.filter = loaded_state.filter;
                options.dataSource.group = loaded_state.group;

                grid.destroy();

                $("#Projects")
                .empty()
                .kendoGrid(options)
            }
        });
    }

There is Kendo Grid definition code:

@(Html.Kendo().Grid<issueTracker.Model.Project>()
    .Name("Projects")
    .Pageable()
    .Columns(col => 
        {
            col.Bound(p => p.ProjectID).Hidden(true);
            col.Bound(p => p.ProjectName);
            col.Bound(p => p.Description);
            col.Bound(p => p.ImagePath);
            col.Command(comm => { comm.Edit(); comm.Destroy(); });
        })
    .ToolBar(t => t.Create())
    .Sortable()
    .Filterable()
    .ColumnMenu()
    .Editable(edit => edit.Mode(GridEditMode.InLine))
    .DataSource(dt => dt
        .Ajax()
        .Read(r => r.Action("GetData", "Projects"))
        .PageSize(20)
        .ServerOperation(false)
        .Events(e => e.Error("error_handler"))
        .Update(u => u.Action("UpdateProject", "Projects"))
        .Destroy(u => u.Action("DeleteProject", "Projects"))
        .Create(u => u.Action("CreateProject","Projects"))
        .Model(m => m.Id(p => p.ProjectID)))

)

Cezary
Top achievements
Rank 1
 answered on 07 Nov 2014
8 answers
536 views
How would I add icons in a horizontal row on a linear chart?  As I figure it, I would need to do two things:
  1. First, I would need to "extend" the chart's vertical "majorGridLines" so that there was room to add a row of icons/images without overlapping the data.
  2. Second, I would need a method to add an image for each x-axis point and be able to specify the y-location (position) at which it was drawn.  Ideally, the the image's file name would come from the data set.
Is this what chart annotations are intended to handle?  I have not been able to find any information on annotations, other than they were introduced in 2013 Q2.

I have attached an image of what I am describing. 

Thank you for your assistance.
Iliana Dyankova
Telerik team
 answered on 07 Nov 2014
2 answers
387 views
Hi,

All code below runs on NodeJS/Express/EJS.
I have a two file form.js and grid.js.

In the form.js I create grid object and define custom validator like here:
-------------------------------------------------------------------------------------------------
...
rest.get(uri, {}).on('complete', function (data, result) {
         var schemeGridColumns = {};
         ...
         schemeGridColumns["field1"].validation = {
                                                                          required: true,
                                                                          custom: function (input) {
                                                                                  if (input.is("[name=field1]") && input.val().length > 5)  {
                                                                                          input.attr("data-custom-msg", "My notification from validator.");
                                                                                          return false;
                                                                                   }
                                                                                   return true;
                                                                    }
       ...
       var grid = {
              editable: {
                    mode: "popup",
                    ....
              },
             transport: {
             ..... 
             },
             ...
            dataSource: {
                   ....
                   schema: {
                          data: 'data',
                          total: 'total',
                          model: {
                               id: gridKeys,
                               fields: gridSchemaFields
                          }
                   }
            },
           ....
      };

      res.render("grid.js", grid: grid, ....);
)};
--------------------------------------------------------------------------
File grid.js looks like this:
----------------------------------------------------------------------------
<div id="grid" style1="float:left"></div>
<div class="clear1"></div>

<script language="javascript">
    $(document).ready(function() {
        titan.setTitle('<%= title %>');

        // create Kendo UI Grid
        $('#grid').kendoGrid(<%- JSON.stringify(grid) %>);

    });
</script>
--------------------------------------------------------------------------------
The problem is that standard validation require works in popup,
but custom doesn't fire. I've tried with inline mode. Result is the same.
May be problem with EJS template compiler?






Ilya
Top achievements
Rank 1
 answered on 07 Nov 2014
5 answers
426 views
I have an MVC 4, EF 5 model first project with these models:
  • Contractor
  • Profile
Between these two is a many-to-many relation. (in the background EF generates a ContractorProfiles table and I'm can get a list of profiles for a contractor by calling Contractor.Profiles)
I would like to use the MultiSelectFor to be able to select one or more profiles for my contractor and directly bind it to my viewmodel but I don't know how to do this.
How can this be done?
Daniel
Telerik team
 answered on 07 Nov 2014
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
Drag and Drop
Map
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
Chat
MultiColumnComboBox
Dialog
DateRangePicker
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Accessibility
Effects
PivotGridV2
Licensing
ScrollView
Switch
TextArea
BulletChart
QRCode
ResponsivePanel
Wizard
CheckBoxGroup
Localization
Barcode
Breadcrumb
Collapsible
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
TimePicker
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
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
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?