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

[Solved] MVC Grid With DataKeys as DateTime

1 Answer 178 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pradeep N
Top achievements
Rank 1
Pradeep N asked on 17 Aug 2010, 10:56 AM
Hi,
I can't able to use the DateTime type as a datakey. I am going to use Command.Delete and i want the DateTime key on the action result for the delete but the action result is not getting triggered.

If i changed the type from datetime to string the actionmethod is triggered and the value is obtained in the parameter. If its datetime the action method is not triggered.
I have attached my code below,

<%= Html.Telerik().Grid<TimeSlot>()
        .Name("TimeSlotList")
                .DataKeys( keys =>
                {
                    keys.Add(o => o.Id).RouteKey("id");
                    keys.Add( o => o.TimeZone).RouteKey("timezone");
                    keys.Add( o => o.StartTime).RouteKey("starttime");
                } )       
        .Columns(colums =>
        {
            colums.Bound(o => o.Id);
            colums.Bound(o => o.TimeZone);
            colums.Bound( o => o.StartTime );
            colums.Bound( o => o.EndTime );
            colums.Bound( o => o.Booked );
            colums.Bound( o => o.Transaction.TransactionNumber );
            colums.Command(commands => {
                                           commands.Edit();
                                           commands.Delete();
            }).Title("Commands");
        })
            .DataBinding(dataBinding => dataBinding.Ajax().Select("Ajax_Index", "TimeSlot")
                                                           .Delete("Ajax_Delete", "TimeSlot")
                                                            .Update("Ajax_Edit","TimeSlot")
                                                       )
        .Scrollable( scrolling => scrolling.Height( 600 ) )
        .Sortable()
        .Pageable(page => page.PageSize(13))
        .Filterable()
        .Groupable()
    %>

[AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public virtual ActionResult Ajax_Delete(string id, string timezone, DateTime starttime)
        {
            var timeslotList = DeleteTimeSlot();
            return View(new GridModel(timeslotList.ToList()));
        }

The above method is not triggered if the starttime type in the Model is System.DateTime.

My Another query is i can't use Delete Command alone. I have to use Edit along with Delete which i don't want in this scenario.

Thanks,
Pradeep. 

1 Answer, 1 is accepted

Sort by
0
Pradeep N
Top achievements
Rank 1
answered on 20 Aug 2010, 02:23 PM
Hi guys,
Is this a bug or i am doing it wrong??? Any update???
Regards,
Pradeep
Tags
General Discussions
Asked by
Pradeep N
Top achievements
Rank 1
Answers by
Pradeep N
Top achievements
Rank 1
Share this question
or