Telerik Forums
UI for ASP.NET MVC Forum
2 answers
409 views
How to add a kendo button in nodatatemplate of autocomplete widget in MVC. Sample screenshot is attached.
Ajith
Top achievements
Rank 1
 answered on 03 Feb 2020
1 answer
8.3K+ views
I am trying to port a Telerik MVC extentions view to a KendoUI view and I am running into a problem.

The view has a grid and a client detail template which also contains a grid. The detail grid is databound (Ajax) to another datasource than the parent grid. In the detail grid I have a client template column. Problem is that in the client template of the detail grid I can only access the fields from the parent grid, not the fields from the detail view grid. This used to work perfectly in the Telerik MVC extentions.

The parent grid
@(Html.Kendo().Grid(Model)
        .Name("UserManagement")
        .DataSource(dataBinding =>
        {
                dataBinding.Ajax().Read( read => read.Action("_UserManagement", "Account"))
                                    .Create( create => create.Action( "CreateUser", "Account"))
                                    .Model( model => model.Id( u => u.Id ));
        })
        .ToolBar(commands =>
        {
            commands.Create().HtmlAttributes(new { @class = "action pie" });
        })
        .Columns(column =>
                {
                        column.Bound(c => c.Name).Title(ViewResources.UserManagement.Username.ToUpper());
                        column.Template(@<text></text>)
                            .ClientTemplate( "<input type='button' class='action pie' value='" + ViewResources.UserManagement.ResetPw +
                                                "' onclick='onResetPassword( #= Id #, \"#= Name #\" )'/> " +
                                                "<input type='button' class='action pie' value='" + ViewResources.UserManagement.Delete +
                                                "' onclick='onDeleteUser( #= Id #, \"#= Name #\" )'/>")
                        .HtmlAttributes(new { style = "text-align: center;" })
                        .Width(400);
                })
        .Editable(editing => editing.Mode(Kendo.Mvc.UI.GridEditMode.InLine))
        .Pageable()
        .Sortable()
        .Filterable()
        .Events(e => e.DataBound("onDataBound"))
        .ClientDetailTemplateId("userRoleLinkTemplate")
)

And the detail grid:
<script id="userRoleLinkTemplate" type="text/kendo-tmpl">
@(Html.Kendo().Grid<RoleUserLinkModel>()
        .Name("RoleLinks_#=Id#")
        .DataSource(dataSource => dataSource.Ajax().Read( read => read.Action( "_UserRoles", "Account", new { userName = "#= Name #" })))
        .Columns(column =>
        {
                column.Bound(r => r.IsLinked)
                    .Title("")
                    .ClientTemplate("<input type='checkbox' class='styled' name='checkedLinks_#= RoleId #_#= UserId #' onclick='Urv_onCheckChange(#= RoleId #, #= UserId #, this.checked)'/>")
                    .Width(36)
                    .Sortable(false)
                    .HtmlAttributes(new { style = "text-align:center" })
                    .Filterable(false);
                column.Bound(r => r.RoleName)
                    .Title(ViewResources.UserManagement.RoleColumn);
        })
        .Pageable()
        .Sortable()
        .Filterable()
        .Events(e => e
                .DataBound("setupStyling"))
        .ToClientTemplate()
)

In the ClientTemplate of the detail grid I want to access the RoleId and UserId fields of the row but I get the "ReferenceError: RoleId is not defined" message. Scoping it using 'data.RoleId' also does not work because then 'data.RoleId' is replaced with 'undefined'.

Any ideas?
Tsvetomir
Telerik team
 answered on 03 Feb 2020
9 answers
1.1K+ views
Here is the grid:

this.Html.Kendo().Grid<Model>()
      .Name("grid")
      .Filterable()
      .ColumnMenu()
      .Sortable()
      .Groupable()
      .ToolBar(commands => { commands.Custom().Name("foo").Text("Perform Action").Action("PerformAction", "ViewPayrollEmployeeDetail"); })
      .Scrollable(scrollable => scrollable.Height(430))
      .Columns(col =>
      {
          col.Bound(x => x.CompanyId).Visible(false);
          col.Template(x => x.CompanyName).ClientTemplate(Html.ActionLink("#= CompanyName #>", "Update", "AppCompany", new { id = "#= CompanyId #", panel = 1 }, null).ToHtmlString()).Width(120);
      })
      .Pageable(pageable => pageable
          .ButtonCount(5)
          .Info(true))
      .DataSource(dataSource => dataSource
          .Ajax()
          .PageSize(25)
          .Read(read => read.Action("GetData", "EmployeeHistory").Data("sendAntiForgery")))

As you can see, I am trying to use CompanyName and CompanyId to render the ActionLink.

When the grid renders, I get this error in javascript:

Uncaught ReferenceError: companyid is not defined

CompanyId is in a nav property a couple of domain model levels down, but I have mapping set up with Deflattening so Kendo knows where to find it for sorting/grouping, etc.

The question is, am I doing this right, and how can I get this to work?  We use these kinds of links everywhere in our current grids, so getting this to work is very important for us.

Thanks!

Mike
Peter Milchev
Telerik team
 answered on 31 Jan 2020
3 answers
313 views

I have a date/time picker in a popup editor that I use javascript to set a default date when the editor opens.  The javascript is able to change the value of the date/time picker but the value is not binding to the grid, hence not saving to the server.  The record saved will show null for the date field. 

 

How do I set a default date to a date/time picker via javascript and have it bind to the record upon saving?

 

 

Kong
Top achievements
Rank 1
 answered on 30 Jan 2020
3 answers
178 views

Hello,

I cannot get working hiding the address bar for my mobile hybrid application on the mobile device (Samsung Galaxy S10).
See attached screenshot.

 

Here is my initialization code of the mobile application:

[code]

@(Html.Kendo().MobileApplication()
      .ServerNavigation(true)
      .Layout(Model)
      .HideAddressBar(true)        
      .Events(e => e.Init("onInitApplication"))
      .Transition("slide")
       .Skin("nova"))

[/code]

Any ideas what I do wrong. Is there any "workaround" to hide the address bar on the mobile device (iphone, android phones, ...)

Greetings

Ivan Danchev
Telerik team
 answered on 30 Jan 2020
2 answers
114 views

Hello,

 

is it possible to open a modal view and show a remote HTML page of PDF Document inside the modal view content?
I only see, that you can add own html in the "Content" Block.

 

If its not possible with the modal view, is there any control that allows me to do that. I would like to show HTML pages or PDFs in a "non fullscreen window", which should be on top of my main window. So modal window would be perfect ...

 

Greetings

Dimitar
Telerik team
 answered on 30 Jan 2020
2 answers
486 views

I have an in-cell editable grid grid in which the values available in a grid foreign key column should be filtered by an input a user has previously selected. In our case a user picks a location from a kendo dropdown (outside of the grid) and that value filters what products should appear in the product foreign key column.

The general idea is that location 1 might have products A, B, and C. But Location 2 might only have products C and D. If the user picks location 1 then the multiselect bound to the foreign key column should only show A, B, and C, and if the user picks location two then they only see C and D when the dropdown is rendered.

I've seen examples where you change the editor template for Foreign Key to bind the dropdown to a remote datasource. In that case the read passes in whatever data the server needs for filtering (location id in our case) as data to the controller read call (https://www.telerik.com/forums/filtered-foreign-key-drop-down-list-based-on-another-key). The server then returns the filtered list of select list items which are bound to the dropdown. 

We'd really like to avoid the case where every time a user opens the dropdown we hit the server. Is there any way to do this filtering on the client side?

I'm envinsioning a case where we: 

  • Send down all of the associations of locationId to productId and bind this to a javascript object
  • Bind the column to a list of all possible products (so the dropdown template on the column object has all possible options)
  • When the user clicks on the cell and the grid renders the dropdown we (in a javascript function) remove the values that aren't valid for the existing location 

Is there an event we could bind to, or a way we could customize the editor template to achieve our desired result, specifically to filter the items in the dropdown without binding to a remote datasource?

Thanks!

 

Aleksandar
Telerik team
 answered on 29 Jan 2020
5 answers
212 views

Hi guys,

 

it seems the Drawer Control is broken since a few Kendo Versions in Internet Explorer 11. I am using currently the latest 2020 version of the Kendo controls (v2020.1.114). The bug seems to be introduced somewhere 2019, I assume. For example, version v2019.3.1023 also has this bug.

 

How to reproduce:

Just click on the Drawer-Icon (to open the Navigation), but nothing happens. This problem only happens in Internet Explorer 11 (Dev Tools: Emulation -> Apple Safari ). In Chrome and Edge it seems to work fine, also on my mobile device (Samsung Galaxy S10).

In older Kendo version (e.g: 2018.1.221) it works fine, but there are other problems which are fixed in the latest 2020 version, so I cannot step back...

 

Thanks for your help,

Greetings

BigzampanoXXl
Top achievements
Rank 1
 answered on 28 Jan 2020
3 answers
798 views

Hi Guys,

A quick one: I understand the concept of grabbing the grid state via "grid.getOptions", then persisting this, and then applying it again via "grid.setOptions" on form refresh to keep the users' sort/filter/column options, etc between sessions. There are posts and help for this already.

 

My question is this:

  • In our situation, we do the above persistence, and store the options string somewhere (e.g. database).
  • However, we may well change the set of columns that the grid needs to display when we do an application version update. It's likely that we would remove, or add columns for example.
  • So, if we have try to apply an options set to the grid that has some columns missing or added since the "save" of the options... what happens?

Does it:

  • Robustly (silently ignore) options we are trying to apply for columns that no longer exist in the grid?
  • Robustly (apply a default) for columns that do not have any options being applied? (e.g. newly added columns).
  • Throw errors, but still render?
  • Fail to render with errors?
  • Something else?

cheers

Nick

 

 

 

hunidoc.com developers
Top achievements
Rank 1
 answered on 28 Jan 2020
1 answer
605 views

I am getting "Uncaught Error: Invalid template:" while trying to request the ".cshtml" page which contains the Kendo Grid (Column-Responsive). We used column responsive template in this grid. I am looking for the solution for this error since couple of hours now but I do not able to resolve it. Please have a look at the below response error message along with the HTML Code.

 

Uncaught Error: Invalid template:'
<div class="container-fluid" onclick="window.location='http://dev.newsalesbook.abc.com/Account/AccountDetail?AccountID=#=data.AccountID #&BusinessUnitID=#=data.BusinessUnitID #'">
   <div class="row">
      <div class="col-xs">
         <label style="font-size:17px; color:rgb(5,69,126); font-weight:bold">#=nullString(data.Name)#</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">Business Unit:</label>
      </div>
      <div class="col-xs">
         <label class="label-md">#=nullString(data.BusinessUnit)#</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">Account Type:</label>
      </div>
      <div class="col-xs">
         <label class="label-md">#=nullString(data.AccountType)#</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">Account#:</label>
      </div>
      <div class="col-xs">
         <label class="label-md">#=data.AccountNo#</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">Parent Account:</label>
      </div>
      <div class="col-xs">
         <label class="label-md">#=nullString(data.ParentAccount)#</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">OS#:</label>
      </div>
      <div class="col-xs">
         <label class="label-md">#=data.OutsideSalesNo#</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">Outside Sales Name:</label>
      </div>
      <div class="col-xs">
         <label class="label-md">#=nullString(data.OutsideSalesName)#</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">IS#:</label>
      </div>
      <div class="col-xs">
         <label class="label-md">#=data.InsideSalesNo#</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">IS Name:</label>
      </div>
      <div class="col-xs">
         <label class="label-md">#=nullString(data.InsideSalesName)#</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">Date Created:</label>
      </div>
      <div class="col-xs">
         <label class="label-md">#=formatDate(data.DateCreated)#</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">Account Owner:</label>
      </div>
      <div class="col-xs">
         <label class="label-md">#=nullString(data.OwnerName)#</label>
      </div>
   </div>
</div>
' Generated code:'var $kendoOutput, $kendoHtmlEncode = kendo.htmlEncode;with(data){$kendoOutput='\n\n   
<div class="container-fluid" onclick="window.location=\'http://dev.newsalesbook.wesco.com/Account/AccountDetail?AccountID='+(data.AccountID )+'&BusinessUnitID='+(data.BusinessUnitID )+'\'">
   \n       
   <div class="row">
      \n\n           
      <div class="col-xs">\n                <label style="font-size:17px; color:rgb(5,69,126); font-weight:bold">'+(nullString(data.Name))+'</label>\n            </div>
      \n       
   </div>
   \n\n       
   <div class="row">
      \n           
      <div class="col-xs">\n                <label class="label-md-bold">Business Unit:</label>\n            </div>
      \n           
      <div class="col-xs">\n                <label class="label-md">'+(nullString(data.BusinessUnit))+'</label>\n            </div>
      \n       
   </div>
   \n\n       
   <div class="row">
      \n           
      <div class="col-xs">\n                <label class="label-md-bold">Account Type:</label>\n            </div>
      \n           
      <div class="col-xs">\n                <label class="label-md">'+(nullString(data.AccountType))+'</label>\n            </div>
      \n       
   </div>
   \n\n       
   <div class="row">
      \n           
      <div class="col-xs">\n                <label class="label-md-bold">Account'+$kendoHtmlEncode(</label>
      </div>
      <div class="col-xs">
         <label class="label-md">)+'=data.AccountNo';</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">Parent Account:</label>
      </div>
      <div class="col-xs">
         <label class="label-md">;$kendoOutput+='=nullString(data.ParentAccount)';</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">OS;$kendoOutput+=':</label>\n           
      </div>
      \n           
      <div class="col-xs">\n                <label class="label-md">'+(data.OutsideSalesNo)+'</label>\n            </div>
      \n       
   </div>
   \n\n       
   <div class="row">
      \n           
      <div class="col-xs">\n                <label class="label-md-bold">Outside Sales Name:</label>\n            </div>
      \n           
      <div class="col-xs">\n                <label class="label-md">'+(nullString(data.OutsideSalesName))+'</label>\n            </div>
      \n       
   </div>
   \n\n       
   <div class="row">
      \n           
      <div class="col-xs">\n                <label class="label-md-bold">IS'+$kendoHtmlEncode(</label>
      </div>
      <div class="col-xs">
         <label class="label-md">)+'=data.InsideSalesNo';</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">IS Name:</label>
      </div>
      <div class="col-xs">
         <label class="label-md">;$kendoOutput+='=nullString(data.InsideSalesName)';</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">Date Created:</label>
      </div>
      <div class="col-xs">
         <label class="label-md">;$kendoOutput+='=formatDate(data.DateCreated)';</label>
      </div>
   </div>
   <div class="row">
      <div class="col-xs">
         <label class="label-md-bold">Account Owner:</label>
      </div>
      <div class="col-xs">
         <label class="label-md">;$kendoOutput+='=nullString(data.OwnerName)';</label>
      </div>
   </div>
</div>
Veselin Tsvetanov
Telerik team
 answered on 28 Jan 2020
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
Dialog
MultiColumnComboBox
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
Security
ColorPicker
DateRangePicker
Wizard
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
LLM Kit
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?