Telerik Forums
UI for ASP.NET MVC Forum
10 answers
3.8K+ views

I have a page that contains a parent grid and a child details grid.  The parent grid uses popup editing and I can control the maxLength of the edit fields on the dialog.  However, the child details grid allows inline editing and one of the fields ("Code") can only be a length of 3 digits.

I have seen other posts and examples using the .attr to set the element's maxlength, but this does not seems to work.

So, within my details grid there is a column called 'Code'.  Inspecting the element while viewing the page in Chrome, shows the edit field to be an <input> element with and Id = 'Code' and Name = 'Code'.  I have tried the following jquery within the DataBound event of the details grid.  I also tried this in the document.ready function.

 

$("#Code").attr('maxlength', '3');

and

$("input[name='code']").attr('maxlength', '3');

 

Any chance of getting this as part of the grid declaration, possibly along with the column.Bound()?

 

Thanks,

Shawn

Georgi
Telerik team
 answered on 11 Oct 2018
1 answer
403 views

Is there a way to make something like this with MVC controls or Kendo UI :

https://demos.telerik.com/aspnet-ajax/fileexplorer/examples/client-sideapi/fileselectordialog/defaultcs.aspx

 

Thanks for your help.

 

 

Veselin Tsvetanov
Telerik team
 answered on 11 Oct 2018
1 answer
144 views

Hi,

 

When I upload a file using the Upload control, I want to be able to change the name of the file on the server, but I want the user to see the original file name.

 

Is there a way to have a different name and value for each file in the list? If so, how is the value set?

 

Thanks,

Jess

Ivan Danchev
Telerik team
 answered on 11 Oct 2018
2 answers
147 views

I apologize if this is a silly question but is it possible that a single grid that has the inline editing capabilities for logged in users and just a read only grid for everyone else? If so where do I start?

Looking at the demo I thought I would have to create 2 grids and password-protect the one with inline-editing.

 

Thanks in advance

Rob
Top achievements
Rank 1
 answered on 10 Oct 2018
3 answers
3.0K+ views

I've found the documentation on how to get the selected value from a drop down list on the DataBound event to be non-existant. 

I eventually found the solution here: https://www.telerik.com/forums/dropdownlist-mvc---set-default-value-at-runtime

It is easy to get the selectedIndex in this event handler. Getting the value that this corresponds to so I can run some custom logic (show/hide fields, for example) when the document is being loaded (as opposed to a select event) was the tricky part.

I already had a generic function I called to obtain this value across the board. I was able to finally solve the issue of getting the selected value when not in the Select event (where the dataItem object is available) using the following code:

var GetValueFromKendoSelect = function (context, e) {
    // if this is from a select event then we'll get the dataitem
    var dataItem = GetDataItemFromKendoSelect(context, e);
    if (dataItem != undefined) {
        return dataItem.Value;
    } else {
        // if this is from a databound event we get it from the sender
        var sender = e.sender;
        if (sender == undefined) {
            console.log("Couldn't retrieve value from Kendo Select list");
            console.log(e);
            return undefined;
        } else {       
            var defaultItem = sender.dataSource.at(sender.selectedIndex);
            return "" + defaultItem.Value;
        }
    }
}

 

I can then use this like this (you can see how it will then generate a usable result in the select and databound events):

var onPassportedBenefitInPaymentSelect = function (e) {       
        var torPassport = GetValueFromKendoSelect(this, e);
        debugger;
        if (torPassport == undefined) {
            console.log("torPassport detected as undefined in torPassportBenefitSelectHandler");
            return false;
        }
        return ProcessTORPassport(torPassport);
    }
 
    var onPassportedBenefitInPaymentDataBound = function (e) {
        var torPassport = GetValueFromKendoSelect(this, e);       
        if (torPassport == undefined) {
            console.log("torPassport detected as undefined in torPassportBenefitOnDataBoundHandler");
            return false;
        }
        return ProcessTORPassport(torPassport);
    }
 
    var ProcessTORPassport = function (torPassport) {
        var $passportedAnsweredGroup = $(".passported-answered-group");
        var $passportedNoGroup = $(".passported-no-group");
        var $passportedYesGroup = $(".passported-yes-group");
        if (torPassport == "" || torPassport == null) {
            $passportedAnsweredGroup.hide();
        } else {
            $passportedAnsweredGroup.show();
        }
        switch (torPassport) {
            case "True":
                $passportedYesGroup.show();
                $passportedNoGroup.hide();
                break;
            case "False":
                $passportedNoGroup.show();
                $passportedYesGroup.hide();
                break;
            default:
                $passportedNoGroup.hide();
                $passportedYesGroup.hide();
                break;
        }
    }

:

Perhaps the documentation could be clearer how this can be achieved, considering how simple it actually is in the end, yet  how difficult it is to find the solution.

Ivan Danchev
Telerik team
 answered on 10 Oct 2018
2 answers
287 views

Hi,

 

I discovered a problem with ClearPromptChar configuration. When I set ClearPromptChar to true, I expect that the mask signs should not be in the output. I.e. when I define mask 000-000 and insert 123-456 into the MaskedTextBoxFor the output should be 123456. I would like to avoid removing "-" manually.

Example available at: http://dojo.telerik.com/aTEROJIG/3

Should it work as I expected or I misunderstood?

 

Thanks,

   Tomas.


Tomáš Víšek
Top achievements
Rank 1
 answered on 09 Oct 2018
1 answer
793 views
Excellent Widget! Really appriciated, but somehow I can't seem to get the headertemplate working. I don't see it appear in the dropdown header. While i inspect the DOM with chrome  dev tools the 'HEADER' phrase is not found. It look's like this method does nothing. or am i mistaken?  And it would also be nice if the widget would have lambda selectors for allmost all property's. Most widget have these selectors, only using string selectors make it error prone (model change is not reflected in this string selector)

@(Html.Kendo().MultiColumnComboBoxFor(m => m)
    .DataTextField("Afkorting")
    .DataValueField("idPersoneel")
    .Filter("contains")
    .FilterFields(new string[] { "Afkorting", "OpgemaakteNaam", "Team" })
    .Columns(columns =>
    {
        columns.Add().Field("Afkorting").Title("Afkorting").Width("50px");
        columns.Add().Field("OpgemaakteNaam").Title("Naam").Width("120px");
        columns.Add().Field("Team").Width("60");
        columns.Add().Field("Omvang").Width("50");
        columns.Add().Field("Resturen").Width("50");
    })
    .HeaderTemplate("HEADER")
    .FooterTemplate("Total \\#: instance.dataSource.total() \\# items found")
    .HtmlAttributes(new { style = "width:100%;" })
    .Height(500)
    .DataSource(ds =>
        {
            ds.Read(read => read.Action("Personeelsleden", "Personeel", new { Area = "Tabellen" }).Data("passPersoneel"));
            ds.Events(e => e.Error("DataSourceRequestErrorHandler"));
        }
    )
    .ToClientTemplate()
)
Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 09 Oct 2018
10 answers
917 views
I've got a grid, with a pop-up edit form, where there is some controller level validation applied before the record is saved.

The grid is defined:-
@(Html.Kendo().Grid<CMS_2013.Models.SeasonalProfile>()
.Name("Grid")
.Events(e=>e.Edit("onEdit"))
.Columns(columns=>
{
 
    columns.Bound(o => o.ID);
    columns.Bound(o => o.Profile_Code);
    columns.Bound(o => o.ProfileType);
    columns.Bound(o => o.Description);
    columns.Bound(o => o.Site);
    columns.Bound(o => o.PATCLASS);
    columns.Bound(o => o.Specialty);
     
    columns.Command(command => { command.Edit(); command.Destroy(); });
 
      
    })
  .ToolBar(commands=>commands.Create())
   .Editable(editable=>editable
        .Mode(GridEditMode.PopUp))
 
 
    .DataSource(dataSource=>dataSource
        .Ajax()
        .Model(m=>m.Id(p=>p.ID))
        .Events(events => events.Error("error"))
        .PageSize(10)
         
         
        .Read(read=>read.Action("ReadProfiles","Profiles"))
        .Create(create=>create.Action("InsertProfile","Profiles"))
        .Update(update=>update.Action("UpdateProfile","Profiles"))
        .Destroy(delete=>delete.Action("DeleteProfile","Profiles"))
        )
        .Pageable()
        .Sortable()
        .Filterable()
   
       )
The error handler is:-
function error(e) {
       if (e.errors) {
           var message = "Errors:\n";
           $.each(e.errors, function (key, value) {
               if ('errors' in value) {
                   $.each(value.errors, function () {
                       message += this + "\n";
                   });
               }
           });
 
 
           alert(message);
          
       }
 
   }

This works fine, displaying the error message if the validation fails. However, I have two problems:-

  1. After displaying the alert, the edit form is closed, so the user can't correct their error - they have to start all over again
  2. Even though the record hasn't been saved - a new record is displayed in the grid, and only after refreshing the grid does it disappear.

How can I solve these two issues?

Thanks

Preslav
Telerik team
 answered on 09 Oct 2018
1 answer
1.0K+ views

Hi, in a grid popup edit template I got a field bound like:

@Html.HiddenFor(model => model.LogoUrl)

This field represents an image URL stored in Azure Blob.

I already got a Kendo Upload in the edit template that upload the image to Azure, but in the KendoUpload success return function, I need to set the URL received by azure in the object currently edited. For now I try this:

function logoUp_onComplete(e) {
    var imgURL = e.response.url;
 
    var img = $("#LogoImage")[0];
    var data = $("#LogoUrl")[0];
 
    if (img != null) {
        $(img).attr("src", imgURL);
        $(data).val(imgURL);
    }
     
}

 

But the databinding are not hit and the underlying model is not changed. How I can achieve that?

Georgi
Telerik team
 answered on 09 Oct 2018
1 answer
239 views

Hi,

I have issue with chart after upgrade kendo libraries to R3 2018 (ver. 2018.3.911.545). Here is my code snippet:

@(Html.Kendo().Chart(Model.ListChartOfProjectHistory)
.Name("MyProjectHistoryChart")
.Series(series =>
{
series.Line(s => s.QuoteValue).Color("#8ACD16").Name("My Projects")
.Tooltip(true);
series.Line(s => s.OfficeQuoteValue).Color("#2698DB").Name("My Office Projects")
.Tooltip(true);
})
.Legend(legend => legend
.Position(ChartLegendPosition.Bottom)
)
.ValueAxis(axis => axis.Numeric().Labels(labels => labels.Format("{0:N0}")))
.CategoryAxis(axis => axis
.Categories(c => c.MonthValue)
)
.Tooltip(tooltip => tooltip.Visible(true).Format("C2"))
.HtmlAttributes(new { style = "border-style:none;height:300px" })
.Events(events => events.LegendItemClick("refreshHistory"))
)

 

and this is my layout with references:

<!DOCTYPE html>
<html>
<head>
    <title>@ViewBag.Title</title>
    <meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE" />
    <link rel="shortcut icon" href="@Url.Content("~/Content/images/favicon.gif")" type="image/x-icon" />
    <link href="@Url.Content("~/Content/Site.css?v=123")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/css/global.css?v=123")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/kendo.dataviz.min.css?ver=1.1")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/kendo.common.min.css?ver=1.1")" rel="stylesheet" />
    <link href="@Url.Content("~/Content/kendo.default.min.css?ver=1.1")" rel="stylesheet" />
    <script src="@Url.Content("~/Scripts/jquery.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/kendo.dataviz.min.js?ver=1.1")"></script>   
    <script src="@Url.Content("~/Scripts/kendo.web.min.js?ver=1.1")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/kendo.aspnetmvc.min.js?ver=1.1")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/corners.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/menu.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

 

I also already updated it with telerik.ui.for.aspnetmvc.hotfix.2018.3.911.commercial libraries but still getting the same error. Fyi my project use MVC 5 and bootstrap 4.

Any thoughts on how to fix this greatly appreciated.

Thanks.

 

Tsvetina
Telerik team
 answered on 08 Oct 2018
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
DropDownButton
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
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
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?