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

Kendo Grid Custom Editable

11 Answers 1059 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sp
Top achievements
Rank 1
Veteran
Sp asked on 18 Jun 2020, 04:16 PM

Hi Team,

I have requirement for custom editable feature there i need to pass a value to editalbe function . So is there any way to pass parameter to Javascript function . i know this function will take dataitem as default parameter instead i want to pass viewbag value along with Dataitem to javascript editable function. 

Hope you understand my problem its very urgent for me , please take a look and help me. waiting for your response.

.Editable("IsEditable('#= ViewBag.Month01 #')");

 

by using this i get only posted value but not Dataitem.

 

Below is my code:

c.Bound(p => p.EditYear).Title("Currency").Visible(false).Locked(false).Width(150);                                                         
c.Bound(p => p.month01FD).Title((string)ViewBag.Month01).Width(colWidthFD).ClientGroupFooterTemplate("#=sum#").ClientFooterTemplate("#=sum#").HtmlAttributes(new { @class = "telerik-edit-cell-inline"}).Editable("IsEditable");

 

i want Dataitem  for EditYear and ViewBag.Month01 needed in javascript. 

Editable("IsEditable"); by using this we will get Dataitem , but not the header of the grid. The header of the column will be in ViewBag . 

Theser are dynamic headers , like this multiple columns will be there based on the header and model for EditYear will determine is this column is editible or not.

Thanks & Regards,
SP

11 Answers, 1 is accepted

Sort by
0
Accepted
Anton Mironov
Telerik team
answered on 22 Jun 2020, 02:27 PM

Hello, 

Thank you for the provided code.

In order to pass a parameter to the function handler try the implementation below:

columns.Bound(p => p.UnitPrice).Width(140).Editable("function(dataItem, additionalParam) { return otherFunction(dataItem, additionalParam); }");

Furthermore, you can find the following article interesting that describes the ViewBag using in JavaScipt in more details:


Let me know if I can help you with anything else.

 

 

Regards,
Anton Mironov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Sp
Top achievements
Rank 1
Veteran
answered on 02 Jul 2020, 09:15 AM

Hi Anton,

 

The solution which you posted worked perfectly for me 

columns.Bound(p => p.UnitPrice).Width(140).Editable("function(dataItem, additionalParam) { return otherFunction(dataItem, additionalParam); }");

Thanks for your support.

 

I have another requirement on grouping . Need your help for the same.

I have a grid with dynamic columns , based on user selected date . i am attaching requirement screen shot as well.

Need to group multiple columns(2 col)  as one line item, second column may vary by year (showing multiple years data).

How can we group columns to show group header differently.

I hope you can understand my requirement by seeing attached file.

Awaiting for your response.

 

Thanks & Regards,

Sp

 

 

0
Anton Mironov
Telerik team
answered on 06 Jul 2020, 09:11 AM

Hi,

In order to change a group name programmatically, try the ClientGroupHeaderColumnTemplatе. Use a JavaScript function as a parameter, implement your conditions in it, and return the desired header text.

Find more information about the Group Templates in the following article:

 

I hope this information helps.

 

Best Regards,
Anton Mironov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Sp
Top achievements
Rank 1
Veteran
answered on 06 Jul 2020, 05:56 PM

Hi Anton,

Thanks for your reply , but my requirement is different here. Let me explain clearly . Based on current date we need to display 18 months data  which it comes dynamically . In that 18 months max of 3 years will come . for example : Aug2020 ....Jan2022. Here i have a currency field which will vary form year to year . so i need to group those columns by year and display group hearder(col1: curreny1)  (col2:currency)

 

Thanks in advance.

 

Regards,

Sp

0
Anton Mironov
Telerik team
answered on 08 Jul 2020, 03:32 PM

Hi,

The grouping functionality, in general, is applied to the data source by one field at a time. Creating a single group by two distinct fields is not possible.

As a workaround, I can suggest creating a helper field that will combine the values of the two other fields. Proof of concept can be found in the example below (the same can be achieved in C# by implementing the concatenation in the getter/setter of the property):

I hope this information helps.


Kind Regards,
Anton Mironov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Sp
Top achievements
Rank 1
Veteran
answered on 27 Aug 2020, 02:57 PM

Hi Team,

I have tried for ClientGroupHeaderColumnTemplatе , but its not recognizing in 2018 mvc grid. could you help me with sample passing model to js and to get the custom header for groupheadertemplate. 

 

2. In my grid i have used two level grouping (used 2 columns for grouping)  we need aggregates for only one column but the grid shows two footers , could you help me how to remove unwanted groupfootertemplate.

 

Thanks,

Sp

0
Anton Mironov
Telerik team
answered on 31 Aug 2020, 01:53 PM

Hello,

It is correct that certain options are missing in the 2018 version of the suite. However, implementing functionalities available in newer versions into older ones is a burdensome task. It would be best if you could update the Kendo UI styles and scripts to the latest along with the Kendo.Mvc.dll. 

As per the footer row, you could make use of the CSS style below that hides it:

.k-footer-template{
    display:none;
}


Best Regards,
Anton Mironov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Sp
Top achievements
Rank 1
Veteran
answered on 03 Sep 2020, 05:51 PM

Hi Team,

We have upgraded both scirpts and styles as well.

Using this snippet , all footer rows are not displaying . But i want one footer template need to be shown. 

.k-footer-template{ display:none; }

 

Thanks & Regards,

Purnima.

 

0
Anton Mironov
Telerik team
answered on 04 Sep 2020, 02:49 PM

Hello,

Thank you for the additional details.

In order to hide the required footers try to add an HtmlAttribute to the needed ones. Here is an example:

// Code:
columns.Bound(c => c.Discontinued).Width(200).ClientFooterTemplate("#=someFunction()#").HtmlAttributes(new { @class = "hiddenFooterTemplate"})

// Styles:
.hiddenFooterTemplate{
    display:none;
};
I hope this information helps!

Kind Regards,
Anton Mironov
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

0
Sp
Top achievements
Rank 1
Veteran
answered on 07 Sep 2020, 01:59 PM

Hi  Team,

Actually my problem is In my grid 

 .Group(groups => groups.Add(p => p.City))
 .Group(groups => groups.Add(p => p.State))

and used ClientGroupFooterTemplate("#=kendo.format('{0:0}',sum)#") each column . 

 

Now my issue is Grid showing two footer templates . I want to show only one footer template for entire row.

2. On cancel click still footers getting added , need solution for this as well.

 

Thanks & Regards,

Sp

 

0
Tsvetomir
Telerik team
answered on 09 Sep 2020, 10:03 AM

Hi,

My name is Tsvetomir and I am temporarily covering for my colleague Anton.

I have added two groups to a Kendo UI Grid and I have noticed that there is only one footer rendered. Please find the sample project attached to my response. 

Is it possible for you to show exactly what is the exact element you are willing to hide?

 

Kind regards,
Tsvetomir
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Sp
Top achievements
Rank 1
Veteran
Answers by
Anton Mironov
Telerik team
Sp
Top achievements
Rank 1
Veteran
Tsvetomir
Telerik team
Share this question
or