Telerik Forums
UI for ASP.NET MVC Forum
2 answers
390 views
I am using server-side validation for some model properties when editing in a ListView with an editor template. The errors are generated from a custom ValidationAttribute. The errors are generated properly, and I am able to display them when the Update button is pressed, but the ListView exits the edit mode, and I would like to prevent this so that the user can update the values.

Sample model property:
[CompareValues("PEEP", CompareValues.GreatThanOrEqualTo, ErrorMessageResourceName = "MAPGreaterThanPEEP", ErrorMessageResourceType = typeof(VentSettingStrings))]
public decimal? MAP { get; set; }

The ListView declaration in the view file:
@(Html.Kendo().ListView<VentSetting>(Model.VentSettingsList)
    .Name("listView")
    .TagName("div")
    .ClientTemplateId("ventTemplate")
    .Editable()
    .DataSource(datasource => datasource
        .Events(events => events.Error("handleError"))
        .Model(model => model.Id(m => m.VentSettingId))
        .Read(read => read.Action("ReadVentSettings", "RunDetail"))
        .Create(create => create.Action("CreateVentSetting", "RunDetail"))
        .Update(update => update.Action("UpdateVentSetting", "RunDetail"))
        .Destroy(destroy => destroy.Action("DeleteVentSetting", "RunDetail"))
    )
)

The relevant parts of the EditorTemplate:
@using ELSORegistry.Helpers
@using Kendo.Mvc.UI
@model ELSORegistry.Areas.ECLS.Models.VentSetting
 
<div style="padding:10px">
 
    <span>@Html.LabelWithTooltipFor(model => model.MAP)</span>
    <span>@Html.TextBoxFor(model => model.MAP, new { @class = "k-textbox", style = "width:50px"})</span>
 
    <div class="edit-buttons">
        <a class="k-button k-button-icontext k-update-button"><span class="k-icon k-update"></span>Save</a>
        <a class="k-button k-button-icontext k-cancel-button"><span class="k-icon k-cancel"></span>Cancel</a>
    </div>

</div>

I borrowed the following scripts from an example using the Grid control, and modified (possibly not correctly) for the ListView:
$(function () {
    var listView = $("#listView").data("kendoListView");
 
    $(".k-add-button").click(function (e) {
        listView.add();
        e.preventDefault();
    });
});
 
function handleError(args) {
    if (args.errors) {
        var list = $("#listView").data("kendoListView");
        var validationTemplate = kendo.template($("#validationMessageTemplate").html());
        list.one("dataBinding", function (e) {
            e.preventDefault();
            $.each(args.errors, function (propertyName) {
                var renderedTemplate = validationTemplate({ field: propertyName, messages: this.errors });
                document.getElementById("errorList").innerHTML += renderedTemplate;
            });
        });
    }
};
According to the Grid example, the preventDefault() method should keep it in edit mode, but this does not work for me in ListView. Any help on this, or any other approach to the problem, would be appreciated. Another goal is to provide this as client-side validation as well, but I can save that for another post.

Steve
Top achievements
Rank 1
 answered on 03 Oct 2013
2 answers
274 views
I have a databound listview with the data being displayed via template.  In my template I have a button.  How can I get the associated data item when the button is clicked?

Peter
Top achievements
Rank 2
 answered on 03 Oct 2013
4 answers
311 views

Hi,

The attached sample project is based on your combo box sample post along with other elements.  

In this project combo box onchange event does not fired if it has numeric value.  Below are details for the same.

             1.  I have 2 combo boxes and 1 label in the attached project: Alphabet Combo, Numeric Combo and Selected Value:  Alphabet Combo has values: A-1, B-2, C-3, D-4 and Number Combo has values: 1-A, 2-B, 3-C, 4-D
             2. Select Alphabet combo by pressing letter 'A' or 'B' or 'C' or 'D' by using keyboard, onchange event fired and selected value and selected text will show on label control  (working fine)

             3. But I have done for Numeric Combo same as above, but it won't show selected value and selected text due to onchange event does not fired. 

For testing, 
    -  Alphabet Combo:  Press 'A' by using keyboard and press Tab, it will show the selected value and text
    - Numberic Combo: Press '1' by using keyboard and press Tab, it wont show the selected value and text

Code for above requirement:
1) Alphabet Combo:
     @(Html.Kendo().ComboBox()
                      .Name("AlphabetCombo")
                      .Suggest(true)
                      .Filter("StartsWith").MinLength(0)
                      .HighlightFirst(true)
                      .Placeholder("Select fabric...")
                      .DataTextField("Text")
                      .DataValueField("Value")
                      .BindTo(new List<SelectListItem>() {
                           new SelectListItem() {
                            Text = "Select", Value = "0"   
                          },
                          new SelectListItem() {
                            Text = "A-1", Value = "1"   
                          },
                          new SelectListItem() {
                            Text = "B-2", Value = "2"   
                          },
                          new SelectListItem() {
                            Text = "C-3", Value = "3"   
                          },
                          new SelectListItem() {
                            Text = "D-4", Value = "4"   
                          }
                      })
                     .SelectedIndex(0)
                     .Events(events =>
                      {
                          events.Change("Combo_Change");
                      })
                )

2) Numeric Combo:
      @(Html.Kendo().ComboBox()
                              .Name("SampleData2")
                      .Suggest(true)
                      .Filter("StartsWith").MinLength(0)
                      .HighlightFirst(true)
                      //.Placeholder("Select fabric...")
                      .DataTextField("Text")
                      .DataValueField("Value")
                      .BindTo(new List<SelectListItem>() {
                           new SelectListItem() {
                            Text = "Select", Value = "0"   
                          },
                          new SelectListItem() {
                            Text = "1-A", Value = "1"   
                          },
                          new SelectListItem() {
                            Text = "2-B", Value = "2"   
                          },
                          new SelectListItem() {
                            Text = "3-C", Value = "3"   
                          },
                          new SelectListItem() {
                            Text = "4-D", Value = "4"   
                          }
                      })
                     .SelectedIndex(0)
                     .Events(events =>
                      {
                          events.Change("Combo_Change");
                      })
                )

3) Label to show selected value and text
   <b>Selected Value is : </b> <label id="lblSelectedValue" runat="server"></label>

4) OnChange Event: JavaScript code
      <script language="javascript" type="text/javascript">
        function Combo_Change(e) {
            var combo = e.sender;
            $('#lblSelectedValue').text(combo.value() + ', ' + combo.text());
        }
    </script> 

Please help me to resolve the issue.  Thanks in advance.

.

Daniel
Telerik team
 answered on 03 Oct 2013
1 answer
218 views
Hello,

I have an issue with the Kendo Editor. I save some html using the ViewHtml options as in the screenshot (BeforeSaving). The data gets saved and when reloading it looks like screenshot ( AfterSaving ). 

Can I do anything to get the editor to save as I type it with all the formatting ? Otherwise the html editor is pretty much unusable
Dimo
Telerik team
 answered on 03 Oct 2013
6 answers
631 views
I am having an issue with combo boxes in my Kendo grid when the text includes special characters.

I have this setup...
// Grid column definition
columns.ForeignKey(b => b.OreSourceId, (System.Collections.IEnumerable)ViewData["OreSources"], "Id", "Description")
// Foreign key editor template
 
@using System.Collections
@using Kendo.Mvc.UI
 
@(Html.Kendo().DropDownList()
    .Name("OreSourceId")
    .DataTextField("Description")
    .DataValueField("Id")
    //.Value(Model)
    .SelectedIndex(0)
    .OptionLabel(">> Select <<")   
    .BindTo((IEnumerable) ViewData["OreSources"]))
// Filling of the ViewData
var dbDataService = GetService<IDBDataService>();
ViewData["OreSources"] = dbDataService.ToLookUp<OreSource>();
This generally works perfectly and no issues.
Then suddenly the entire grid stopped functioning properly (after user edits). All combos (there are many in the grid) stopped working, edit mode would not work, and the delete button generated an error (not important what the error is - just saying).

I tracked it down to being a dodgy text value in one of the records being used by the combobox.
This text "21 Central Reef BH 1#*" caused the page to break. If I updated the database and removed the #* then everything works perfectly again.
It is however a requirement by the client that they are able to use special characters as part of their naming conventions so I have to find a way to work around this.

Any ideas please?
Vladimir Iliev
Telerik team
 answered on 03 Oct 2013
1 answer
133 views
Hi,

In the previous version of the controls I have used the theme builder to set the foreground and border color of tabstrip tabs, but this has stopped working since I have upgaded to the current version of the controls.

I have tried to import and edit my previous css in the theme builder on the telerik website, but I cannot find any option that changes these colors now?

Thank you
Iliana Dyankova
Telerik team
 answered on 02 Oct 2013
1 answer
231 views
Hi,

I have a question - maybe something simple and not really linked to Kendo, but to be honest, I just do not know: We want to integrate the scheduler in our web app, so that customers can use this calendar (all together) and then sync it to their mobile devices. I guess this needs to be done via google calendar, windows live or whatever.

Can you point me in some direction? Or is this not possible at all?

Thanks,
Volker
Vladimir Iliev
Telerik team
 answered on 02 Oct 2013
5 answers
944 views
Hi,

I'm using Kendo grid within div and while reading data I'm blocking to prevent user activity on it. I need to put long process cancellation button in order to cancel ajax grid request.
$('#div').block({
message: '<h1 style="color:blue;">אנא המתן...</h1><br><input type="button" value="CANCEL" onclick="cancelSemHours()"/>'
});

On server side I'm supposed to implement following in data read action :
if (!Response.IsClientConnected)
{
    Response.End();
}
How do I implement the client-side cancellation with kendo grid? (cancelSemHours function) 

Thank you in advance,
Waiting for your kind and prompt reply
Shabtai

Alexander Popov
Telerik team
 answered on 02 Oct 2013
1 answer
124 views
Is there a way (an api) to validate a resource against a date on the server side? I saw the Restrictions demo, but that shows how to handle restriction on the client side using JavaScript. I want to be able to find out if a resource is available at a given date on the server side. I can probably try to make sense of how data is being stored in database and then parse it, but was wondering with all the exceptions and recurrence rules in effect, there might already be something you guys have that I can reuse?

Thanks,
Georgi Krustev
Telerik team
 answered on 02 Oct 2013
1 answer
339 views
Hi, we have a grid that uses the Change event to go to a new screen, but the Change event is fired multiple times. Is this as expected or a bug?  
In the example below, the "Change" dialog is shown twice in Chrome and 3 times in FF.

@(Html.Kendo().Grid<VorDNAModel.SimpleModel.SimpleMixture>()
                        .Name("grid")
                        .Columns(columns =>
                        {
columns.Bound(p => p.MixtureId).Filterable(false).Title("Identification").Width(100);
                            columns.Bound(p => p.ReferenceNumber).Title("Reference #").Width(100);
columns.Bound(p => p.CaseName).Title("Case").Width(100);
columns.Bound(p => p.Description).Title("Description").Width(100);
columns.Bound(p => p.CollectionLocation).Title("Collection Location").Width(100);
columns.Bound(p => p.CollectedOn).Format("{0:MM/dd/yyyy}").Title("Collection Date").Width(100);
columns.Bound(p => p.LabAnalysisDate).Format("{0:MM/dd/yyyy}").Title("Lab Analysis Date").Width(100);
                        })
                        .Pageable()
                        .Sortable()
                        .Scrollable()
                        .Filterable()
                        .Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
                        .Events(events => events.Change("onRowSelectionChanged"))
                        .HtmlAttributes(new { style = "height:740px;" })
                        .DataSource(dataSource => dataSource
                            .Ajax()
                            .PageSize(20)
                            .Read(read => read.Action("ListMixtures", "Mixture"))
                        )
                    )

function onRowSelectionChanged(arg) {
    alert("Change!");
}
Dimiter Madjarov
Telerik team
 answered on 02 Oct 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
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Security
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
SegmentedControl
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?