This is a migrated thread and some comments may be shown as answers.

Grid with Datepicker in Toolbar

4 Answers 743 Views
Grid
This is a migrated thread and some comments may be shown as answers.
vitaliy
Top achievements
Rank 1
vitaliy asked on 25 Mar 2015, 03:51 AM
Hi.
There is grid:
@(Html.Kendo().Grid<OperMVC.Models.Daily>()
    .Name("Grid")
    .Columns(c => {
        c.Bound(p => p.Name).Width(150);
        c.Bound(p => p.BDayDate).Width(50);
    })
    .ToolBar(toolbar =>
    {
        toolbar.Template(
            @<div><label>BDate: </label>
            @(Html.Kendo().DatePicker()
                .Name("datepicker")
                .Events(e => e.Change("GetDate"))
                .Value(DateTime.Today)
                .Format("dd.MM.yyyy")
            )</div>
        );
    })
     
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("ReadBDays", "Person").Data("filterDate"))
        //.ServerOperation(true)
    )
     
 
 
)
and js script for DatePicker Event:
function GetDate() {
        var value = this.value();
        var date = new Date();
        if (value) {
            date.setTime(Date.parse(value));
            console.log(date.toLocaleDateString());
        }
        $("#Grid").data("kendoGrid").dataSource.read();
         
    }
js function for filter data by date:
function filterDate() {
        var date = $("#datepicker").data("kendoDatePicker").value();
        console.log("filtered date:" + date);
        return {dateString : date}
    }


When I select the date, then update the Grid as I need, but if I want to choose a new date, it opens a DatePicker without any a dates. you have to change the month and return back, then there are only dates
Attach screenshot

4 Answers, 1 is accepted

Sort by
0
vitaliy
Top achievements
Rank 1
answered on 25 Mar 2015, 06:31 AM
I Tried to move the DatePicker outside the table - the effect is the same. DatePicker problem?
0
vitaliy
Top achievements
Rank 1
answered on 25 Mar 2015, 07:33 AM
i solved the problem.
0
JSeeger
Top achievements
Rank 1
answered on 08 Apr 2015, 05:16 PM
What was the solution?
0
vitaliy
Top achievements
Rank 1
answered on 09 Apr 2015, 01:01 AM

i used that js scritp to collapse grouped row in my grid on DataBound Event:

function collapseGroupRows() {
        var grid = $("#Grid").data("kendoGrid");
        grid.collapseGroup(grid.tbody.find("tr.k-grouping-row"));
        $('tr[role*="row"]').slice(1).hide();
    }

-  It is troble)

I changed script on:

function collapseGroupRows() {
        var grid = $("#Grid").data("kendoGrid");
        var groups = grid.tbody.find(">tr.k-grouping-row");
        for (var i = 0; i < groups.length; i++) {
            grid.collapseGroup(groups.eq(i));
        }
         
    }

and everything works fine=)

 

Tags
Grid
Asked by
vitaliy
Top achievements
Rank 1
Answers by
vitaliy
Top achievements
Rank 1
JSeeger
Top achievements
Rank 1
Share this question
or