Telerik Forums
UI for ASP.NET MVC Forum
0 answers
101 views

I have a grid, I have added custom validations on multiple columns. It's working as expected. But there is one issue, I am not able to edit other cells if there is any validation error on the cell, So first I need to fix the error for this cell then only I am allowed to edit other cells. But I want that it should show the validation error in the tooltip and as well as to edit other cells.

I have attached the tooltip message in the question.


columns.Bound(config => config.X).Title("X").HeaderHtmlAttributes(new { @class = "grid-headercustom" }).
ClientTemplate("#if(data.X == 1)" + "{#<span>Y</span>#}" + "else{#<span>N</span>#}#").
HtmlAttributes(new { @class = "grid-rowcustom" }).HtmlAttributes(new { style = "font-size:12px" }).Filterable(ftb => ftb.Enabled(false));

 


$.extend(true, kendo.ui.validator, {
    rules: {
        RateV: function (input, params) {
            if (input.is("[name='X']")) {
                var grid = $("#mygrid").data("kendoGrid");
                var row = input.closest("tr");
                var dataItem = grid.dataItem(row);
                if (dataItem.X == true && dataItem.Y <= 0) {
                    input.attr("data-RateV-msg", "X must be greater than zero when the Y is ticked");
                    return false;
                }
            }
            
            return true;
            }
        },
        messages: {
            RateV: function (input) {
                // return the message text
                return input.attr("data-val-X");
            }
        }
    });
})(jQuery, kendo);

 

I have tried to return true also but it doesn't show the error then.

 input.attr("data-RateV-msg", "X must be greater than zero when the Y is ticked");
                    return true;

Vivek
Top achievements
Rank 1
Iron
 updated question on 12 Aug 2021
0 answers
104 views
I have a grid, I have enabled the InCell editing, I want to edit the multiple cells and on a Save button click, I want to validate all the grid data and show the error messages as tooltip (which is shown on validation error) for the respective cells. It should only allow to Save data if all the validations are passed.
Vivek
Top achievements
Rank 1
Iron
 asked on 12 Aug 2021
1 answer
119 views

I have a case where i need to dynamically clone the switch control and use it.
 Im able to clone the switch but the script still refers to the original control .

Tried changing  the id and name properties but still not able to achieve it .

Can anyone let me know how to do it .(FYI im not using mobileswitch)

Thanks in advance.

Anton Mironov
Telerik team
 answered on 12 Aug 2021
1 answer
141 views

Hi,

I have a business requirement to be displayed 100+ bar charts with lines on one page itself while hitting the page. 

Can you please help to do that dynamically?  I'm very much new to this Kendo UI control. 

 

--

Thanks

Ramesh

 

Anton Mironov
Telerik team
 answered on 11 Aug 2021
1 answer
452 views

I want the sum of two columns to be added to another column in the kendo grid. Now it is showing that NaN when I use ClientTemplate whereas in the case of ClientGroupColumnTemplate shows the correct result. In my case, I want the result in another column instead of a group column any help?

.Columns(c =>

    {  c.Bound(p => p.field1).Title("F1");
       c.Bound(p => p.field2).Title("F2");
       c.Bound(p => p.Total).Title("Total").ClientTemplate("#=calculate(data)#");
})

<script>
    function calculate(data) {
        field1 + p.field2;
        return result;

</script>
Anton Mironov
Telerik team
 answered on 11 Aug 2021
1 answer
2.3K+ views

Hello,

Could someone provide sample code for export Grid data to excel?  below is the requirement:

1. This is MVC project

2. Kendo Grid with many pages in the View.

3. button located in the view but not located in the toolbar section of the Grid.

4. When click button, all Grid data (not just View data)  should export to excel file.

 

Thanks.

 

Anton Mironov
Telerik team
 answered on 10 Aug 2021
1 answer
150 views

Hello, 

I try to get dataSource from my MVC project but got syntax error. Could someone tell me what's wrong? Thanks.

Action method on MyController:

        public JsonResult Position_Read()
        {
                var entity = new PositionViewModel
                {
                   POS_ID = "10000",
                   POS_TYPE="INTER",
                   CREATE_DT = DateTime.Now
                };

                return Json(entity);
          }

 

JavaScript in View:

 <script>

        function GetServerSourceData() {
            var ds = new kendo.data.DataSource({
                type: "odata",
                transport: {
                    read: "/MySite/MyController/Position_Read"
                },
                schema: {
                    model: {
                        fields: {
                            POS_ID: { type: "string" }, 
                            POS_TYPE: { type: "string" }
    CREATE_DT: { type: "date" },
                        }
                    }
                }
            });
            return ds;
        } 

 </script>

                         
Anton Mironov
Telerik team
 answered on 10 Aug 2021
0 answers
112 views

I have added custom validation on the grid for multiple columns. It's working as expected. The only problem I am facing is that the tooltip position is not pointing to the current cell, it is pointing to different cells in the same row for all columns. How can I fix it?

 


columns.Bound(config => config.X).Title("X").HeaderHtmlAttributes(new { @class = "grid-headercustom" }).
ClientTemplate("#if(data.X == 1)" + "{#<span>Y</span>#}" + "else{#<span>N</span>#}#").
HtmlAttributes(new { @class = "grid-rowcustom" }).HtmlAttributes(new { style = "font-size:12px" }).Filterable(ftb => ftb.Enabled(false));


$.extend(true, kendo.ui.validator, {
    rules: {
        RateV: function (input, params) {
            if (input.is("[name='X']")) {
                var grid = $("#grid-pricefeedconfiguration").data("kendoGrid");
                var row = input.closest("tr");
                var dataItem = grid.dataItem(row);
                if (dataItem.X == true && dataItem.Y <= 0) {
                    input.attr("data-RateV-msg", "X must be greater than zero when the Y is ticked");
                    return false;
                }
            }
            
            return true;
            }
        },
        messages: {
            RateV: function (input) {
                // return the message text
                return input.attr("data-val-X");
            }
        }
    });
})(jQuery, kendo);
I have attached the screenshot. It should point to checkbox cell but it is pointing to other column which has value 0.
Vivek
Top achievements
Rank 1
Iron
 asked on 09 Aug 2021
1 answer
2.2K+ views

I have a checkbox in a grid that I want to conditionally disable. What I have below technically hides the checkbox (haven't figured out how to conditionally 'disable') but you can still click in the box and the checkbox will appear even if it does not meet the condition:

@(Html.Kendo().Grid<SomeUI.Areas.UVL.Models.SomePOModel> ().Name("SomePOgrid") .Columns(columns => { columns.Bound(p => p.forceClose).Title("Force Close") .ClientTemplate("#if(status == 'Pending'){# <input id='forceClose' value='#=forceClose#' class='k-checkbox' type='checkbox' checked='checked'/> #}#") .Width(170).HtmlAttributes(new { style = "text-align:center;" });

})

Wondering if you have a better or solution or if someone can explain what I am missing. Thanks.
Ivan Danchev
Telerik team
 answered on 09 Aug 2021
0 answers
128 views

Hello,

I am using Kendo for Asp.Net MVC.  With an ImageBrowser on the Editor control, the name returned from the server (which is different from the file name uploaded) is respected, but for the FileBrowser, the returned name is ignored.  How does on get this to work?

    

<PackageReferenceInclude="Telerik.UI.for.AspNet.Core"Version="2021.2.616"/>

 

   
  @(Html.Kendo().Editor()
    .Name(Model.Id)
    .HtmlAttributes(new { style = "height:470px"aria_label = "editor" })
    .Tools(tools => tools
      .Clear()
      .Bold().Italic().Underline().Strikethrough().JustifyLeft().JustifyCenter()
      .JustifyRight().JustifyFull().InsertUnorderedList().InsertOrderedList().Outdent().Indent()
      .CreateLink().Unlink().InsertImage()
      .InsertFile()//.SubScript()//.SuperScript()//.TableEditing()
      .ViewHtml().Formatting().CleanFormatting()
      )
    .ImageBrowser(
      imageBrowser => imageBrowser
        .Transport(transport =>
        {
          transport.Read(r => r.Url($"/api/imageupload/read?franchiseId={Model.FranchiseId}"));
          transport.Create(c => c.Url("/api/imageupload/create"));
          transport.Destroy(d => d.Url("/api/imageupload/destroy"));
          transport.UploadUrl($"/api/imageupload/uploadurl?franchiseId={Model.FranchiseId}");
          transport.ImageUrl("/api/imageupload/imageurl?file={0}");
          transport.ThumbnailUrl("/api/imageupload/thumbnailurl");
        }
        )
        .Schema(schema => schema.Model(
            model => model.Fields(fields => fields
                .Name(name => name.Field("Name"))
                .Size(size => size.Field("Size"))
                .Type(type => type.Field("EntryType"))
                )
            )
        )
    )
    .FileBrowser(
      fileBrowser => fileBrowser
        .Transport(transport =>
        {
          transport.Read(r => r.Url($"/api/docupload/read?franchiseId={Model.FranchiseId}"));
          transport.Create(c => c.Url("/api/docupload/create"));
          transport.Destroy(d => d.Url("/api/docupload/destroy"));
          transport.UploadUrl($"/api/docupload/uploadurl?franchiseId={Model.FranchiseId}");
        }
        )
        .Schema(schema => schema.Model(
            model => model.Fields(fields => fields
                .Name(name => name.Field("Name"))
                .Size(size => size.Field("Size"))
                .Type(type => type.Field("EntryType"))
                )
            )
        )
    )
    .Value(Model.Value)
  )
Burton
Top achievements
Rank 1
 updated question on 09 Aug 2021
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?