Telerik Forums
UI for ASP.NET MVC Forum
4 answers
1.2K+ views
Hi,
I'm trying to use InCell editing with Ajax enabled and a Delete/Destroy button.

@(Html.Kendo().Grid<BreezeU.DAL.UserFile>()
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(p => p.Id).Title("Id").Visible(false);
            columns.Bound(p => p.Title).Title("Name");
            columns.Bound(p => p.LastUpdatedOn).Title("ModifiedDate").Format("{0:MM/dd/yyyy}").Width(140);
            columns.Command(commands =>
            {
                commands.Destroy(); // The "destroy" command removes data items
            }).Width(120);
        })
        .Events(ev => ev.Save(@"function(e){setTimeout(function(){$('#Grid').data('kendoGrid').dataSource.sync()})}"))
        .Editable(editable => editable.Mode(GridEditMode.InCell)) // Use inline editing mode
        .Filterable()
        .DataSource(dataSource => dataSource
            .Ajax()
            .Model(model =>
            {
                model.Id(p => p.Id); // Specify the property which is the unique identifier of the model
                model.Field(p => p.Id).Editable(false); // Make the Id property not editable
                model.Field(p => p.LastUpdatedOn).Editable(false); // Make the date property not editable
            })
            .PageSize(20)
            .ServerOperation(false)
            .Read(read => read.Action("read", "files").Data("getAntiForgery")) // Set the action method which will return the data in JSON format
            .Update(update => update.Action("update", "files").Data("getAntiForgery"))  // Action invoked when the user saves an updated data item
            .Destroy(destroy => destroy.Action("delete", "files").Data("getAntiForgery")) // Action invoked when the user removes a data item
        )
        .Pageable() // Enable paging
        .Sortable() // Enable sorting
        )

Everything in the above code works great except when I click the Delete button. Nothing happens and no call is sent to the sever. 
However, if I simply change it to GridEditMode.InLine then the Delete button works. 

Also, I noticed that when using InCell editing, if I include a Save button in the toolbar, the Destroy operation can be triggered by clicking Save. But this is not the behavior I would like.

Is there anyway to have the Delete button call the destroy method when InCell editing is enabled?

Thanks

Nikolay Rusev
Telerik team
 answered on 19 Dec 2014
1 answer
218 views
Hi,

In my app, I have a scheduler that I try to fill using  the DataSource.Read but it stay empty.
I verified the data arrives to the client but it seems not to be understand by the control.
Here's a bit of code:

@(Html.Kendo().Scheduler<xxx.Website.Models.Lesson>()
    .Name("scheduler")
    .Date(new DateTime(2014, 12, 12))
    .StartTime(new DateTime(2014, 12, 8, 9, 00, 00))
    .EndTime(new DateTime(2014, 12, 5, 14, 00, 0))
    .Height(700)
    .AllDaySlot(false)
    .Views(views =>
    {
        views.WeekView();
    })
            .Resources(resource =>
              {
                  resource.Add(m => m.LessonType).Title("Lesson Type").DataTextField("Text").DataValueField("Value").DataColorField("Color").BindTo(new[]{
                  new { Text = "Group1", Value=1, Color="#DC8166"},
                  new { Text = "Group2", Value=2, Color="#889DAE"},
                  new { Text = "Group3", Value=3, Color="#91DE80"},
                  new { Text = "Group4", Value=4, Color="#FFD24D"}
          });
              })
    .Timezone("UTC")
  .Editable(false)
        .DataSource(d => d
                .Model(m =>
                {
                    m.Id(f => f.Id);
                    m.Field(f => f.Title).DefaultValue("No title");
                })
                .Read(read => read.Action("Read_Scheduler", "Administration").Data("getDates"))
)
)

I already use a scheduler on another page but using the BindTo method which work just fine.
Here I need to call server to update the scheduler when the user change displayed the week.

What do I miss ?

Regards,

David
Georgi Krustev
Telerik team
 answered on 19 Dec 2014
1 answer
166 views
Hi,
I am upgrading from Telerik extensions. The code used to open a window and set the datasource for the grid on that page was:

function openTrainWind(trainID) {
            var window = $("#trainWindow").data("kendoWindow");
            window.ajaxRequest("/Trains/_Trains/", { _trainID: trainID });
            window.center().open();
        }

The code has been upgraded to work with Kendo but produces the error "Uncaught TypeError: undefined is not a function"
How would this code need to change to work with Kendo.

Thanks
Neil
Top achievements
Rank 1
 answered on 18 Dec 2014
3 answers
113 views
Hello,

I have been trying to get the batch grid to work with a file upload. The aim is to update the grid with the information in the text file. Would this be a common scenario which has been tried before? 

For temporary solution, I processed the uploaded file and save it in the server and render the partial view which contain
@html.Kendo().Grid()

Then, during loading of the partial view, the Read( read.Action ("Test","TestController")) is invoked and load the data from the text file.

Is there a way to set the dirty flag manually after the initial load of the grid so that I can click the save button?

Thank you,

-sk 
Dimiter Madjarov
Telerik team
 answered on 18 Dec 2014
2 answers
689 views
I have a situation, in which the Kendo().DropDownListFor isn't working as expected; I'm using a dropdown in a KendoGrid edit popup. The user is allowed to choose a user friendly value for a foreign key.

This is working:

@Html.DropDownListFor(m => m, new SelectList(ViewBag.Partners, "Id", "FriendlyName"), "Select Partner")

But this is not:

@(Html.Kendo().DropDownListFor(m => m)
    .BindTo(new SelectList(ViewBag.Partners, "Id", "FriendlyName"))
    .OptionLabel("Select Partner"))

In both cases, the dropdown is displayed correctly, and the initial value is correctly selected.
However, when saving, the Id field is cleared. When I look at the generated HTML markup, this is a part of it:

<ul unselectable="on" class="k-list k-reset" tabindex="-1" role="listbox" aria-hidden="true" id="PartnerId_listbox" aria-live="off" style="overflow: auto; height: auto;"><li tabindex="-1" role="option" unselectable="on" class="k-item">Select Partner</li><li tabindex="-1" role="option" unselectable="on" class="k-item">Indicia Test SFTP</li><li tabindex="-1" role="option" unselectable="on" class="k-item">Indicia Test Mail</li><li tabindex="-1" role="option" unselectable="on" class="k-item">Indicia Test FS</li><li tabindex="-1" role="option" unselectable="on" class="k-item k-state-selected k-state-focused" id="PartnerId_option_selected" aria-selected="true">Test Jesse</li></ul>

As you can see, no Id's are in the markup, which I find suspicious.

Here is how the ViewBag.Partners value is populated (in the controller):
/// <summary>
/// Populates the partners.
/// </summary>
protected void PopulatePartners()
{
    ViewBag.Partners = Database.Partners.Select(pg => new { pg.Id, pg.FriendlyName }).ToArray();
}

What is going on here? Why is the normal Html.DropDownListFor working, while Kendo's version isn't?
Indicia
Top achievements
Rank 1
 answered on 18 Dec 2014
13 answers
257 views
Hi I have a list of items in a multiselect and I want them to be received in the order that the user has specified when being sent to the controller

Right now they seem to be sorted by whatever the datasource is sorted by.

Any tips?
Alexander Popov
Telerik team
 answered on 18 Dec 2014
1 answer
783 views
Hi,

I've created a simple MVC 5 project with a Kendo grid to display a few records from a remote server. When i run the application, the kendo grid appears but displays no records. 
I checked Fiddler and found no errors or circular references. Furthermore, the JSON output shows the correct data in it but its simply not displaying in the grid. Here is the grid and controller code:

<div style="width:830px;font-size:x-small; padding-top:40px;">
 
        @(Html.Kendo().Grid<SystemsFormsMVC.Models.vMyForm>()
 
        .Name("Grid1")
 
        .Columns(columns=>
 
        {
 
            columns.Bound(o => o.Id);
 
            columns.Bound(o => o.SystemName);
 
            columns.Bound(o => o.FormType);
 
 
            })
              
 
            .DataSource(dataSource => dataSource
 
             .Ajax()
 
             .PageSize(5)
 
             .Read(read => read.Action("GetMyForms", "Home"))             
 
                )
 
                .Pageable()
 
                .Navigatable()
 
                .Sortable()
 
                .Filterable()
 
            )
</div>

Controller:
public ActionResult GetMyForms([DataSourceRequest] DataSourceRequest request)
{
    var query = _repository.GetMyForms(GetCurrentUserName());
    query = query.OrderBy(s => s.RequestDate);
    return Json(query, JsonRequestBehavior.AllowGet);
}
 
  
 
public IQueryable<vMyForm> GetMyForms(string UserName)
{
    SystemsFormsDataContext db = new SystemsFormsDataContext();
    IQueryable<vMyForm> query;
    Int32 UserId = GetCurrentUserId(UserName);
 
    try
    {
        query = (from s in db.vMyForms
                 where s.UserId == UserId
                 select s);   
    }
    catch (Exception ex)
    {
        query = (from s in db.vMyForms
                 where s.UserId == 0
                 select s);
    }
 
    return query;
}

Could you please help me figure out what the issue is with the data not displaying in the grid?

Thanks,  Shuja

Georgi Krustev
Telerik team
 answered on 18 Dec 2014
10 answers
169 views
I am reviewing the  new export to Excel feature in version 2014.3.1119.   This feature is really nice, but I cannot find a way to correctly export a grid with dropdownlists.   The export shows the column, but include the foreign key, not the dropdownlist text.   The new Export to PDF works correctly and downloads the text for the dropdownlist.    Is there a way to get the Export to Excel to work correctly on dropdownlists?

Thanks for your help.
Gayathri Rao
Top achievements
Rank 1
 answered on 18 Dec 2014
2 answers
125 views
I have a treeview with remote data binding. Every time I expand a node it does a GET with the parent Id as parameter. Is it possible change the GET for a POST?

The reason to do this is for security. We either need to encrypt the parameter on the GET or change it as a POST.
Ana Clara
Top achievements
Rank 1
 answered on 17 Dec 2014
1 answer
833 views
Hi,

We've just come to integrating our product which uses the Telerik.UI.for.AspNet.Mvc5 NuGet package and we get errors stating that it cannot be found. Having looked at Nuget.org, it seems that it has disappeared.

Any reason for this, or is there an alternative location that I can use? I notice a ZIP file in my Product download page. I guess I need to host that locally. THough I would like confirmation that the original NuGet repository package has disappeared - and why considering this will break a lot of builds.

Thanks

Nathan
Sebastian
Telerik team
 answered on 17 Dec 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?