Telerik Forums
UI for ASP.NET MVC Forum
1 answer
824 views

Hello all,

 

I have a problem with save one row. Here is my code:

DataSource:

var localDataSource = new kendo.data.DataSource({
            batch: true,
            transport: {
                read: function (options) {
                    $.ajax({
                        url: "Content/JSON/GridData.json",
                        success: function (result) {
                            options.success(result);
                        },
                        error: function (result) {
                            options.error(result);
                        }
                    });
                },
 
 
                update: function (options) {
                    console.log("update call");
                    options.success();
                }
            },
            schema: {
                model: {
                    id: "Id",
                    fields: {
                        Name: "Name",
                        Position: "Position"
                    }
                }
            }
        });

 

 Kendo grid:

var grid = $("#grid").kendoGrid({
           dataSource: localDataSource,
           editable: true,
           toolbar: ["save", "cancel"],
           columns: [
             {
                 command: {
                     name: "saveOneRow", text: "save", click: function (e) {
                         var row = $(this).closest('tr');
                         grid.editRow(row);
                         grid.saveChanges(); // save all
                     }
                 }, title: " ", width: "180px"
             },
             { field: "Name", width: "100px", title: "Name" },
             { field: "Position", width: "100px", title: "Position" },
              
           ],
       }).data('kendoGrid');

 

Save all and cancel all works fine.

But how can I save one row?

(because localDataSource.sync() (save all) and localDataSource .read() (cancel all).)

 

p.s. I tried command {name: "save"}, but he didn`t fire any event

 

Thanks

Rosen
Telerik team
 answered on 21 Aug 2015
1 answer
77 views

I want to use the date category axis which should only show years:

@(Html.Kendo().Chart().Name("CompetenceEvolution")

.SeriesDefaults(sd => sd.Line().Style(ChartLineStyle.Smooth))
.Series(series =>
{
foreach (var data in Model.EvolutionChartData)
{
series.Line(data.Items).Field("Score").CategoryField("AssessmentDate").Name(data.Name);
}
})

.CategoryAxis(axis => axis.Date().BaseUnit(ChartAxisBaseUnit.Years))

...

but I would like that for plotting the points the real date is used (now the point is placed above the category label), but is should be placed according to the date. Because now, when having two different items in the same year (with a different date), only one item is getting plotted to the chart.
           

Iliana Dyankova
Telerik team
 answered on 21 Aug 2015
0 answers
132 views

Ok my requirement is simple and I am just getting lost in the various partial examples and forum posts on how to do this. What is surprising is I would expect this to be so standard there would hundreds of examples out there but I cannot find one.

 

I have a basic person model with properties to include a birthdate.  All of those properties are on a grid in a MVC 5 Razor view.  The grid is setup and works fine.  What I would like to do is keep the existing filter capability on the birthdate field but add four additional filters that signify age groupings, so one for under 11 years old, one for between 11 and 14, and one for between 14 and 18, and one for over 18.

 

Then of course since this is not a field in the actual database, I would need to do "custom server binding" as all the partial examples somewhat show. I have played with the datasourcerequest object in the past and I have no need to implement a fill blown custom binding scenario. Is it possible to just intercept these four requests, pull them out of the IFilterDescriptors, apply them manually, and then pass the remaining request object to the ToDataSourceResult method?

If so I have not seen this either. If someone could please guide me to the right area on this I would appreciate it. To sum up:

1. How do you add custom filters to the grid menu on a column but keep the default ones there?

2. Can you intercept these filters and pull them out of the filter descriptor collection?

3. How would you identify these custom filters to pull them out?

Andrew
Top achievements
Rank 1
 asked on 21 Aug 2015
2 answers
176 views
I have Two relational KendoGrids on same MVC View. I need to apply CRUD operations for both the grids. Please suggest me the best approach to do Insert/Update/Delete operations for both the grids altogether.
Mahendra
Top achievements
Rank 1
 answered on 20 Aug 2015
2 answers
723 views

I have a kendogrid:

 @(Html.Kendo().Grid<OAIWebInterface.Models.Leadership>()
                            .Name("LeadershipGrid")
                            .Columns(columns =>
                            {
                                columns.Bound(c => c.LeadershipID).Width(150);
                                columns.Bound(c => c.Organization).Width(150);
                                columns.Command(command => { command.Edit(); }).Width(95);
                            })
                            .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("LeadershipEditorTemplate"))
                            .HtmlAttributes(new { style = "max-height: 350px;" })
                            .DataSource(dataSource => dataSource
                                .Ajax()
                                .Model(model => model.Id(p => p.LeadershipID))
                                .Read(read => read.Action("Leadership_Read", "AnnualSummary", new { ASId = Model.AnnualSummaryID}))
                                .Update(update => update.Action("LeadershipPopup_Update", "AnnualSummary"))
                            )
                        )​

 

I have a Editor Template called "LeadershipEditorTemplate" in which I got the following code:

    @Html.RadioButtonFor(x => x.Reimburse, true)Yes
      @Html.RadioButtonFor(x => x.Reimburse, false)No

 

On edit kendo row, one of the radio buttons in the editor template do not get checked. For example, Yes should be checked when the Reimburse value is true/1 and No should be checked when the value is set to false/0.

 I verified that Reimbuse has a value when in template, but can't make it work with radio buttons.

 I would appreciate any input on this issue.

Thanks.

 

Sindhura
Top achievements
Rank 1
 answered on 20 Aug 2015
1 answer
266 views

Hello 
I have question how to refresh control after edit?

I tried:

  • return all data after upadte but this doesn't work
public JsonResult Update([DataSourceRequest] DataSourceRequest request, ProductCategoryViewModel category)
       {
           if (ModelState.IsValid)
           {
               var services = new ProductCategoryServices(db);
               services.Update(category, ModelState);
           }
 
           var result = db.ProductCategories.ToTreeDataSourceResult(request,
                               cat => cat.ProductCategoryId
                               , cat => cat.FKParentProductCategoryId
                               , cat => cat.ToProductCategoryViewModel(request)
               );
 
           return Json(category, JsonRequestBehavior.AllowGet);
          // return Json(new[] { category }.ToTreeDataSourceResult(request, ModelState));
       }
  • - also add some events like:
    - requestEnd it is call only once
    - complete added to update action in trasport but this work also only once and only if inside is alert function
  • event onSave on TreeList also doesn't work

PS. Stupid question but where is edit post option? :)

Genady Sergeev
Telerik team
 answered on 20 Aug 2015
1 answer
325 views

Hi Team,

 I am using kendo UI editor and image browser in MVC View in form of HTML. I have to upload an image. I have created one action method and bound to the upload function of image browser. When i upload, image gets saved to the location and after that an automatic thumbnail call goes to app which has a url and pass the path parameter which is the file name. In case of new file upload it pass the path value to undefined. In upload action i am returning json response in form of:

 var json = new    {              name = Path.GetFileName(file.FileName),

                    type = "f",

                    size = file.ContentLength
                };
                return Json(json, "text/plain");

 

Thumbnail action method is the default action method of  EditorImageBrowserController class which i am using.

Please let me know if i am missing anything or do i need to override thumbnail action. If yes please provide me example.

Thanks.

Dimo
Telerik team
 answered on 20 Aug 2015
2 answers
170 views

Has anyone got any advice on the best way to get Lat and Long from a postcode?

 It needs to be embedded into a commercial application so I understand we may have to pay for a license from Google, Bing , etc.

 Anyone doing this?

Mark
Top achievements
Rank 1
 answered on 20 Aug 2015
3 answers
166 views

Hi,

Is it possible, that dataSource.sync(); causes a double postback if using a slow connection ?

It looks like that the client postback twice if the server doesn't reply within e.g. 15 seconds.

The code:

var dataSource = $("#" + gridname).data("kendoGrid").dataSource;
dataSource.sync();
Is it something you have seen before - if not, then I guess I'll have to find it somewhere else in my code :-)

Are there any good ways to prevent double postbacks using the kendo framework?

Thanks.

 

Kiril Nikolov
Telerik team
 answered on 20 Aug 2015
3 answers
137 views

Hi,

I am trying to use the @Html.Kendo().Grid(Model) to generate a row template, but it doesn't do what I want... The code I have so far is:

 

@(Html.Kendo().Grid(todayFocus)
    .Name("TodaysFocus")
    .Columns(columns =>
    {
        columns.Template(c => { }).ClientTemplate(" ").Title("Today's Focus");
        columns.Template(c => { }).ClientTemplate(" ").Title("Mid Day");
        columns.Template(c => { }).ClientTemplate(" ").Title("End Dday");
        columns.Template(c => { }).ClientTemplate(" ").Title("Plan");
        columns.Template(c => { }).ClientTemplate(" ").Title("Target");
    })
      .RowTemplate(grid => @<text>
                                <td>@item.TaskName</td>
                                <td>@item.MidDay</td>
                                <td>@item.EndDay</td>
                                <td>@item.Plan</td>
                                <td>@item.Target</td>
                            </text>)
)

 And what I am getting for each row is:

<tr>
    <td colspan="5"> /<td>
    <td>Task Name</td>
    <td>10</td>
    <td>20</td>
    <td>30</td>
    <td>40</td>
</tr>

Why am I getting the extra <td colspan="5"> and how do I get rid of it?

Thanks

Dimiter Madjarov
Telerik team
 answered on 20 Aug 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?