Telerik Forums
UI for ASP.NET MVC Forum
1 answer
389 views
On my current project, we make extensive use of the kendo grids. However, I'm not happy with our re-use strategy, which consists of cutting and pasting known-good templates into each view that needs them. Is there documentation that describes how to, for instance, turn a template into a partial view? The trick is that, since these are client grids, I need to pass selection data into them somehow as well.

Here's a code example of what we're doing:
<script id="feedbackFormTemplate" type="text/kendo-tmpl">
@(Html.Kendo().Grid<Intranet.Data.Review.Info.FeedbackFormInfo>()
        .Name("CRTFeedbackForm_#=Pernr#")
        .Columns(columns =>
        {
           columns.Template(@<text></text>).ClientTemplate("<div>CRT Reviewed Date : \\#=SubmissionDateString\\# | \\#=CorrectiveActionName\\# | \\#=SectionName\\# </div>");
     
    })
        .ClientDetailTemplateId("crtReasonTemplate")
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("CRTGetByInvestigatorAndCaseNumber", "FeedbackForm", new { pernr = "#=Pernr#", caseNumber=@Model.Case.CaseNumber }))
        )
        .Events(e => e
            .DataBound("hideHeader")
        )
        .ToClientTemplate()
            )  
</script>

<script id="crtReasonTemplate" type="text/kendo-tmpl">
     @(Html.Kendo().Grid<Intranet.Data.Review.Info.FeedbackFormReasonInfo>()
        .Name("reason_#=FeedbackFormId#")      
        .TableHtmlAttributes(new { @class = "noHideHeader" })   
        .Columns(columns =>
        {
            columns.Bound(p => p.ItemNumber).HtmlAttributes(new { style="width: 8%"});
            columns.Bound(p => p.ItemType).HtmlAttributes(new { style = "width: 8%" });
            columns.Bound(p => p.ItemOrg).HtmlAttributes(new { style = "width: 8%" });
            columns.Bound(p => p.ItemEventDateString).HtmlAttributes(new { style = "width: 8%" });
           
            columns.Bound(p => p.FeedbackReasonName).HtmlAttributes(new { style = "width: 45%" });
            columns.Bound(p => p.RebuttalStatus).HtmlAttributes(new { style = "width: 15%" });
        })
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("GetReasonsByFeedbackFormId", "FeedbackForm", new { feedbackFormId = "#=FeedbackFormId#" }))
        )
        .ToClientTemplate()
    )
</script>

The bottom template in particular is re-used verbatim in many different places. I  tried doing this:

<script id="crtReasonTemplate" type="text/kendo-tmpl">
    @{ Html.RenderPartial("_CustomerReworkFeedbackReasonTemplate", new Intranet.Web.Areas.QTrack.ViewModels.CustomerReworkReasonTemplateViewModel { FeedbackFormId = feedbackFormId}); }
</script>

But it doesn't like the way I'm trying to transmit the feedbackFormId variable.

Thanks in advance for any assistance you can provide.
Petur Subev
Telerik team
 answered on 11 Jul 2013
3 answers
490 views
Dear KendoUI Team!
I hope you can help me out. I want to update some Editor Templates from the old Telerik Controls. I am using ASP.Net MVC 4.

My Editor Template looks like this

@model string
@using System.Collections
<div style="white-space:nowrap;">
 
 
    @Html.TextBoxFor(m => m, new { onclick = "setInvisible(\"SplitCountryList#=Rid#\")", onfocus = "setInvisible(\"SplitCountryList#=Rid#\")", id = "CoPrefSplit#=Rid#" })
    <button id="SplitCountryDisplay" onclick="setVisibleAndFocus('\\#SplitCountryList#=Rid#','\\#SplitCountryCombo-input')" style="background-color:White; width: 20px; height:22px; font-size: 6pt">...</button>
</div>
 
<div id="SplitCountryList#=Rid#" style="position: absolute; overflow:visible; width:250px; z-index:99; margin-top: 0px; visibility:hidden;">
@(Html.Kendo().ComboBoxFor(m => m)
        .Name("SplitCountryCombo#=Rid#")
        .BindTo(new SelectList((IEnumerable)ViewData["Countries"], "Code", "DisplayName"))
        .HtmlAttributes(new {@ArticleID = "#=Rid#"})
        .Filter(FilterType.Contains)
        .Events(events => events
            .Change("onSplitCountryChanged")
        )
    )
</div>

What I want to do is to set the value of the Textbox in the Change Event of the Combo-Box. My Approach is using .val()

$(elementName).val(e.sender.dataItem().Value);

The value displayed in the Textbox is changed then. BUT: The value transfered to the server is the old value of the Textbox.

Example:
The field has the value "US".  I edit the row.  I change the value to "CN" using the Combobox. "CN" is now displayed in the textbox in edit mode. When I want to update the row, "US" is provided as the value for the field in the model.

Is there a way to make kendoUI transfer the values that are displayed?

brgds
Malcolm Howlett
Vladimir Iliev
Telerik team
 answered on 11 Jul 2013
14 answers
599 views
I'm getting a JavaScript error after I apply grouping.
Unable to get property 'length' of undefined or null reference kendo.web.min.js, line 10 character 28275
Step 1. See attached Drag to GroupBy row.png - Load the page and group any column
Step 2. See attached JavaScript error when GroupBy.png, I get the JavaScript error.

The code I am using looks to me to be identical to the Custom AJAX Binding sample code included in the examples, but I am getting this error?

.CSHTML
@(Html.Kendo().Grid<Fluid>()
    .Name("Grid")
    .Columns(columns => {
        columns.Bound(o => o.FluidID).Groupable(false);
        columns.Bound(o => o.Name);
        columns.Bound(o => o.Code);
        columns.Bound(o => o.Grade);
        columns.Bound(o => o.Manufacturer);
    })
    .Deferred()
    .Pageable()
    .Sortable()
    .Filterable()
    .Scrollable()
    .Groupable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("GetJsonData", "FluidKendo"))
    )
)


Controller Code:
public ActionResult GetJsonData([DataSourceRequest] DataSourceRequest request)
{
    List<Fluid> allFluids = MockFluids();
    // When drag column header into group by row the following JavaScript error occurs
    // JavaScript error IE: SCRIPT5007: Unable to get property 'length' of undefined or
    // null reference kendo.web.min.js, line 10 character 28275
    // JavaScript error Chrome: Uncaught TypeError: Cannot read property 'length' of undefined
    // --- Example taken from the Custom AJAX Binding example: CustomAjaxBindingController.cs
    var resultThatErrors = new DataSourceResult();
    resultThatErrors.Data = allFluids;
    resultThatErrors.Total = allFluids.Count();
 
    return Json(resultThatErrors);
}
If anyone is interested I have a Visual Studio 2012 Sample App to show the error download here: https://skydrive.live.com/redir?resid=3113F9DB92CC84B2!1997&authkey=!Nefhm5WSin4%24

Refer to the attached Highlighted VS solution items.png for the highlighted items of interest.

Thanks,
Beau


Beau
Top achievements
Rank 1
 answered on 11 Jul 2013
2 answers
218 views
Can someone point me to an example of using the GroupFooterTemplate with the MVC Server Wrappers?

From what I can tell, this should work when I 'group by' any column:
.GroupFooterTemplate( f => "Sum: " + f.Sum )

Is there any other setup / configuration that's needed to make it work?

Edit:
I've add this to the DataSource as well without success
.Aggregates( a => a.Add(c => c.Quantity).Sum())
Tom
Top achievements
Rank 1
 answered on 10 Jul 2013
1 answer
145 views
Dear KendoUI Team!
Please help out! Attached you find a project with Editortemplates in a nested table.
Please try the following:
- Open Editortemplate 'Country3.cshtml'
- Change Serverfiltering to true
- run the website
- try to edit a row
- you will experience an 'invalid template' error
I you change serverifltering to false the 'invalid template' error is gone.
But I need server filtering there!
What is going on? What can I do?

brgds
Malcolm Howlett
Malcolm
Top achievements
Rank 1
 answered on 10 Jul 2013
3 answers
161 views
I am using the Kendo UI Upload control with the Knockout-Kendo.js project's binders.  I have a file upload control on my form and am seeking to upload the file through the ajax callback provided by the Knockout-Kendo.js api.  Most of the time, the upload goes through successfully, but every once in a while, so far only on IE, there's an issue and I get a javascript error saying "SCRIPT5: Access is denied."   I've read that IE9 has security rules that can cause this error in certain situations, but I do not understand well enough how the kendo ui control works (or how the knockout-kendo library works) to understand what I might need to change to prevent the error.  Any ideas will be very much appreciated!

Here is a simplified version of my code:
In the view:
<input name="fileUpload" type="file" id="fileUpload" data-bind="kendoUpload: $root.fileUploadSettings()" />

In the javascript viewmodel:
var fileCategory = "myCategory";
 
fileUploadSettings = function () {
        var kendoSettings = {
            multiple: false,
            enabled: true,
            async: { saveUrl: "../Entity/AddFiles" },
            success: function (e) { _uploadFileSuccess(e, fileCategory); },
            error: function (e) { _uploadFileError(e, fileCategory); },
            select: function (e) { _uploadFile(e, fileCategory); },
            localization: { select: "Upload File" },
        };
In the MVC controller: 
[HttpPost]
public ActionResult AddFiles(File data, System.Web.HttpPostedFileBase fileUpload)
{
    try
    {
        File file = FileUIService.AddFile(data, fileUpload);
        FileView rfv = new FileView()
        {
            Id = file.Id,
            Name = fileUpload.FileName.Substring(fileUpload.FileName.LastIndexOf('\\') + 1)
        };
 
        return Json(rfv, "text/plain");
    }
    catch (Exception ex)
    {
        return Json(ex.Message, "text/plain");
    }
}
Daniel
Telerik team
 answered on 10 Jul 2013
0 answers
58 views
Please refer the attached file.
Prasad
Top achievements
Rank 1
 asked on 09 Jul 2013
3 answers
1.7K+ views
I'm trying to change the color of the grid command button but the CSS is not taking effect.  The CSS is being called because the font size is changing.  The color is not for some reason.  Any ideas.


CSS:
.editButtonChangeColor
{
background-color: Red;
color: Red;
border-color: Red;
font-size: 20px;
}

Databound function of grid:
$(".k-grid-edit").addClass("editButtonChangeColor");
Dimiter Madjarov
Telerik team
 answered on 09 Jul 2013
2 answers
271 views
I looked at the code sample at http://www.kendoui.com/code-library/mvc/grid/export-grid-to-excel.aspx
It uses AJAX binding.
Can this be done using server binding? I am having some issues with ajax binding.

Thanks

Jagdish
Top achievements
Rank 1
 answered on 08 Jul 2013
1 answer
82 views
The Model has 4 properties, Description, Amount, Note and a boolean, NoteRequired.
I have a grid with 3 columns, Description, Amount and Note.  
If NoteRequired is True for a row and the Amount > 0, how do I show them a message that a Note is Required and set the focus in the Note field?

Dimo
Telerik team
 answered on 08 Jul 2013
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
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
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?