Telerik Forums
UI for ASP.NET MVC Forum
2 answers
574 views

How can I specify the id of the record as an optional parameter in the UrlAction?

@model IEnumerable<proITdesk.Database.Models.Address>

...

<script type="text/x-kendo-tmpl" id="template">

    <a href='@Url.Action("Details", "Addresses", new { Id = "#=Id#" }.ToString())'>
        <div class="widget-primary">
            <h4 style="text-align:center">#:Name#</h4>
            <img src="@Url.Content("~/content/web/foods/")#:Id#.jpg" alt="#:Name# Image" />
        </div>
    </a>
</script>     
Harald
Top achievements
Rank 2
 answered on 16 Jul 2017
8 answers
405 views

My website was working fine till last week, during which there seems to have been a chrome update.

The issue is right when my page loads, we have a search field, but the cursor does not display, even after i click with mouse pointer on the text box. I am able to type and do search, but the cursor does not appear, which says there is something wrong.

But once inside, I have another masterpage and here there are few jQuery validations. But even after the user enters the required values, keep getting "Those values required" error message. We use jquery validate, but even after we tried kendo validator the same issue remains. I cannot proceed from this page.

Once i close the browser and come back, the issue seems to be resolved some time. But its very inconsistent and we cannot suggest that to production. FireFox has no issues, so its something related with Chrome.

If i am loading the page in developer mode (F12), there seems to be no issue too. This happens only in the deployed version and right after clearing the cache of the browser. It has to be do with some scripts not loading, but I am not able to test it since, all scripts are loaded and working when doing it in developer mode.

IT
Top achievements
Rank 1
 answered on 14 Jul 2017
10 answers
261 views

I have a treeview set up as below ("treeview"), and the rendered checkboxes are not styled according to the theme (bootstrap).  If I set up another treeview with local data ("treeview1"), they render as themed.  Any hints as to how i can get the checkboxes to adhere to the theme when using a datasource?

 

NOT THEMED:

@(Html.Kendo().TreeView()
        .Name("treeview")
        .Checkboxes(checkboxes => checkboxes.Name("checkedCategories")
        .CheckChildren(true))
        .Events(events => events.Check("onCheck"))
        .DataTextField("description")
        .DataSource(dataSource => dataSource
            .Model(m => m.HasChildren("HasChildren").Children("Children"))
            .Read(read => read.Action("GetFilters", "ProductList")))
          )

THEMED:

@(Html.Kendo().TreeView()
        .Name("treeview1")
        .Checkboxes(checkboxes => checkboxes.Name("checkedCategories"))
        .Items(treeview =>
       {
           treeview.Add().Text("Asset Class").Id("1-1")
               .Expanded(true)
               .Items(category =>
               {
                   category.Add().Text("My first thing").Id("2-1");
                   category.Add().Text("My Second Thing").Id("2-2");
               });
       }))

Magdalena
Telerik team
 answered on 14 Jul 2017
9 answers
338 views
Kendo MVC 2014.3.1516

Bug:
If you use a MultiSelectFor in an EditorTemplate, the grid's "save" event will only fire once for that cell.  The second time you update the same cell (by picking an additional item or removing an item from the MultiSelect list), the grid's save event is not called.
Georgi
Telerik team
 answered on 14 Jul 2017
2 answers
243 views

Hi, 

I have created an ASP.NET MVC c# project and I have added two grids using the hierarchy option.  parent grid contains Orders Header records and child grid contains Orders details records, into grid child we need to use an telerik autocomplete mvc control here start the problem because is not working.  The two grids has been created using Razor syntax into the view, and the idea is create a CRUD into Parent Grid and into Child Grid, I mean when  you create a new header row (parent grid) you can add rows into child grid (master - detail behavior)

Using Column.Bound() into child grid, I have tried to use the ".Template" and ".ClientTemplate" method and even EditorTemplateName (using other cshtml view) but is not working.  Please note the autocomplete control must be visible when you create a new record or edit old record in detail grid.

 

What is the best way to do this task?

 

Any help, many thanks.

Preslav
Telerik team
 answered on 14 Jul 2017
7 answers
375 views

Hi,

I am using http://demos.telerik.com/aspnet-mvc/upload/chunkupload to upload video file around 2 GB using chunk of 10 MB, all setting in config has been done.

It worked on Firefox, Chrome and IE with no issue, great tool.

But when I tried to upload using safari on windows 10 OS, the same code do not worked and it seems it is in infinite loop and file size keeps increasing...

Config setting is as below:

 <httpRuntime targetFramework="4.5" maxRequestLength="2147483647"/>

<security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2147483647"/>
      </requestFiltering>
 </security>

.cshtml:

@(Html.Kendo().Upload()
    .Name("files")
    .Async(a => a
        .Save("ChunkSave", "Upload")
        .Remove("Remove", "Upload")
        .AutoUpload(true)
        .ChunkSize(20000000) // Will separate the file into chunks of size 1100 bytes.
        .Concurrent(true) // Will upload all files simultaneously.
        .AutoRetryAfter(300) // Will attempt a failed chunk upload after 300ms.
        .MaxAutoRetries(4) // Will attempt the same failed chunk upload 4 times.
    )
)

C# code:
  public void AppendToFile(string fullPath, Stream content)
        {
            try
            {
                using (FileStream stream = new FileStream(fullPath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
                {
                    using (content)
                    {
                        content.CopyTo(stream);
                    }
                }
            }
            catch (IOException ex)
            {
                throw ex;
            }
        }

        public ActionResult ChunkSave(IEnumerable<HttpPostedFileBase> files, string metaData)
        {
            if (metaData == null)
            {
                return Save(files);
            }

            MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(metaData));
            var serializer = new DataContractJsonSerializer(typeof(ChunkMetaData));
            ChunkMetaData chunkData = serializer.ReadObject(ms) as ChunkMetaData;
            string path = String.Empty;
            // The Name of the Upload component is "files"
            if (files != null)
            {
                foreach (var file in files)
                {
                    path = Path.Combine(Server.MapPath("~/App_Data"), chunkData.FileName);

                    AppendToFile(path, file.InputStream);
                }
            }

            FileResult fileBlob = new FileResult();
            fileBlob.uploaded = chunkData.TotalChunks - 1 <= chunkData.ChunkIndex;
            fileBlob.fileUid = chunkData.UploadUid;

            return Json(fileBlob);
        }


        public ActionResult Save(IEnumerable<HttpPostedFileBase> attachments)
        {
            //The Name of the Upload component is "attachments".
            foreach (var file in attachments)
            {
                //Some browsers send file names with a full path. You only care about the file name.
                var fileName = Path.GetFileName(file.FileName);
                var destinationPath = Path.Combine(Server.MapPath("~/App_Data"), fileName);

                file.SaveAs(destinationPath);
            }

            //Return an empty string to signify success.
            return Content("");
        }

Can any one help me if I did something wrong?

Nencho
Telerik team
 answered on 14 Jul 2017
2 answers
414 views

Hi

I have a kendo template that uses resources and one of the german resorces has an umlaut. The template is loaded using kendo.template and kendo.render.

I found a link that complains about this http://www.telerik.com/forums/german-umlauts-not-working-in-listview%27s-client-template-when-coming-from-resources but the solution from there does not work: Html.Raw

I have tried also 
@Html.Raw(HttpUtility.HtmlEncode(Resources.GridSaveChanges).Replace("#", "\\#"))

but it does not work.

Alexandra
Top achievements
Rank 1
 answered on 14 Jul 2017
3 answers
211 views

I currently have a dropdown list with Virtualization which shows the dropdowns as follows "First Middle Last (XXX-XX-XXXX)". When typing in the seach box I can successfully search based on name or SSN with dashes. However I would like to be able to search on SSN without dashes. I tried attaching another property to the viewmodel sent from the lookup controller but am unable to figure out how to achieve what I want while still preserving the dashes in the UI. My thought was to catch the filter and apply regex on it serverside that if only number had been entered then to add dashes after 3rd and 5th character which would allow me get my desired output.

Here is the View:

01.@Html.LabelFor(model => model.VisitorID)
02.                    @(Html.Kendo().DropDownList()
03.                      .Name("VisitorID")
04.                      .DataTextField("Value")
05.                      .DataValueField("ID")
06.                      .MinLength(2)
07.                      .HtmlAttributes(new { style = "width:100%" })
08.                      .Height(290)
09.                      .Filter(FilterType.Contains)
10.                      .DataSource(source =>
11.                      {
12.                          source.Custom()
13.                              .ServerFiltering(true)
14.                              .ServerPaging(true)
15.                              .PageSize(80)
16.                              .Type("aspnetmvc-ajax") //Set this type if you want to use DataSourceRequest and ToDataSourceResult instances
17.                              .Transport(transport =>
18.                              {
19.                                  transport.Read("Virtualization_GetVisitor", "Lookups");
20.                              })
21.                              .Schema(schema =>
22.                              {
23.                                  schema.Data("Data") //define the [data](http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.data) option
24.                                        .Total("Total"); //define the [total](http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.total) option
25.                              });
26.                      })
27.                      .Virtual(v => v.ItemHeight(26).ValueMapper("VisitorLookups"))
28.                      .NoDataTemplate("<a onclick=\"addNewEntityPartial(\'Visitor\');\">Add a new Visitor</a>")
29.                    )
30.                    @Html.ValidationMessageFor(model => model.VisitorID)

 

The C# For virtualization:

01.#region VisitorLookup
02.            public ActionResult Virtualization_GetVisitor([DataSourceRequest] DataSourceRequest request)
03.            {
04.                return Json(GetVisitor().ToDataSourceResult(request));
05.            }
06.            public ActionResult Visitor(int[] values)
07.            {
08.                var indices = new List<int>();
09. 
10.                if (values != null && values.Any())
11.                {
12.                    var index = 0;
13. 
14.                    foreach (var visitor in GetVisitor())
15.                    {
16.                        if (values.Contains(visitor.ID))
17.                        {
18.                            indices.Add(index);
19.                        }
20. 
21.                        index += 1;
22.                    }
23.                }
24.                return Json(indices, JsonRequestBehavior.AllowGet);
25.            }
26. 
27.            private IQueryable<LookupViewModel> GetVisitor()
28.            {
29.                var ro = User.IsInRole("ReadOnly");
30.            return db.Visitors.Select(visitor => new LookupViewModel
31.            {
32.                ID = visitor.ID,
33.                Value = (visitor.Flag == true ? "FLAGGED " : "") +
34.                        visitor.FirstName + " " +
35.                        visitor.MiddleName + " " +
36.                        visitor.LastName +
37.                        " (" + (ro ? "XXX-XX-XXXX" : visitor.SSN.Replace("-", "")) + ") " +
38.                        (visitor.Flag == true ? "FLAGGED" : ""),
39.                SSN = (ro ? "XXX-XX-XXXX" : visitor.SSN.Replace("-", ""))
40.                });
41.            }
42.            #endregion

 

I feel like I'm very close but am not quite sure how to modify the filter in the request on line 4 (second snippet) to achieve what i want.

Below was the path I was on:

01.public ActionResult Virtualization_GetVisitor([DataSourceRequest] DataSourceRequest request)
02.        {
03.            Regex regex = new Regex(@"[\d]");
04.            foreach (var filter in request.Filters)
05.            {
06.                if (regex.IsMatch(((FilterDescriptor)filter).ConvertedValue.ToString()))
07.                {
08. 
09.                    if (((FilterDescriptor)filter).Value.ToString().Length > 2)
10.                    {
11.                        ((FilterDescriptor)filter).Value.Insert(2, "-");
12.                    }
13.                    if (((FilterDescriptor)filter).Value.ToString().Length > 4)
14.                    {
15.                        ((FilterDescriptor)filter).Value.Insert(4, "-");
16.                    }
17.                }
18.            }
19.            return Json(GetVisitor().ToDataSourceResult(request));
20.        }

But that does not compile since Insert can't be made on a Object.

 

Any help?

Veselin Tsvetanov
Telerik team
 answered on 14 Jul 2017
2 answers
601 views

Hi guy's,

 I've been doing my best to find a solution on the forum and google but can't find what I'm looking for.

I have a grid which uses a toolBar template for the "add" button.

@(Html.Kendo().Grid(Model.WorkingDays)
      .Name("WorkEffortRecordsGrid")
      .DataSource(ds =>
          ds.Ajax()
              .Read(read => read.Action("GetWorkingDay", "WorkRecordEffort").Data("getTimezoneOffset"))
              .Create(create => create.Action("SaveWorkRecordEffort", "WorkRecordEffort").Data("getTimezoneOffset"))
              .Update(update => update.Action("UpdateWorkRecordEffort", "WorkRecordEffort").Data("getTimezoneOffset"))
              .Group(groups => groups.Add(p => p.Activity.Name))
              .Model(model => model.Id(viewModel => viewModel.Id))
      )
      .Columns(columns =>
      {
          columns.Bound(viewmodel => viewmodel.WorkRecord.Name).Title(Strings.WorkRecordId).ClientTemplate("#= (typeof WorkRecord === 'undefined')? '' : WorkRecord == null ? '' : WorkRecord.Name #");
          columns.Bound(viewmodel => viewmodel.Summary);
          columns.Bound(viewModel => viewModel.Task.Name).Title(Strings.TimeTaskName).ClientTemplate("#= (typeof Task === 'undefined')? '' : Task == null ? '' : Task.Name #");
          columns.Bound(viewModel => viewModel.StartTime).ClientTemplate("#= StartTime == null ? '' : kendo.toString(StartTime, \"t\") #");
          columns.Bound(viewModel => viewModel.EndTime).ClientTemplate("#= EndTime == null ? '' : kendo.toString(EndTime, \"t\") #");
          columns.Bound(viewModel => viewModel.Duration);
          columns.Command(commands =>
          {
              commands.Edit().UpdateText(Strings.Save);
          });
      })
      .AutoBind(true)
      .ToolBar(toolBar =>
      {
          //toolBar.Create().Text("default add").HtmlAttributes(new { onclick = "Ps.onCreate()" });
          toolBar.Template("<a class='k-button k-button-icontext' onclick='Ps.onCreate()' href='#'></span>Create</a>");
      })
      .Editable(editable => editable.Mode(GridEditMode.PopUp).Window(w => w.Width(610)).TemplateName("WorkRecordEffortEditor"))
      .Filterable()
      .Events(events => events.Edit("Ps.onEdit").DataBound("Ps.onDataBound"))
)

 

with a javascript function which has to do some business logic through ajax calls

/**
* When Add is clicked
*/
export function onCreate() {
    // clear the error message if it exists
    $('#errorMessages').html("");
 
    // do ajax call to the server to check if all existing records have end times
    $.ajax({
        type: 'POST',
        url: Urls.checkEndTimes,
        dataType: "JSON",
        success: allHaveEndTimes => {
            // if all records have end times
            if (allHaveEndTimes) {
                // show the editor box
                alert("here - true - show the editor box");
            } else {
                // show the error message
                $.ajax({
                    type: 'POST',
                    url: Urls.showErrorMessage,
                    contentType: 'application/json',
                    dataType: "html",
                    success: response => {
                        $('#errorMessages').html(response);
                    }
                });
            }
        },
        error: function () {
            alert("somethings gone wrong... this is not good...");
        }
    });
}

 

I haven't figured out how to make the editor display when the response comes back as true ("allHaveEndTimes")

Anybody have any ideas?

 

Thanks

Tom

Tom
Top achievements
Rank 1
 answered on 13 Jul 2017
3 answers
1.1K+ views

Hi there,

I’ve a grid with a column that is using a DropDownList as the template. It works as expected but I need to change the width of the dropDownList’s list.
How can I do that?

 

Here's the grid's code

01.@(Html.Kendo().Grid(Model)
02.    .Name("grid")
03.    .Columns(columns =>
04.    {
05.        columns.Command(command =>
06.        {
07.            command.Destroy().Text("Eliminar");
08.        }).Width(100).Title("Comandos");
09.        columns.Bound(c => c.Empleado)
10.            .ClientTemplate("#=Empleado.NumeroExpediente# - #=Empleado.Nombre#"
11.                + " #=Empleado.Apellido1# #=Empleado.Apellido2#")
12.            .Title("Empleado")
13.            .Width(190);
14.    })
15.    .Editable(x => x.Mode(GridEditMode.InCell))
16.    .DataSource(dataSource => dataSource
17.        .Ajax()
18.        .ServerOperation(false)
19.        .Batch(true)
20.        .Destroy("DeleteSubContrato", "Crear")
21.        .Model(model =>
22.        {
23.            model.Id(p => p.ID);
24.            model.Field(p => p.ID).DefaultValue(0);
25.            model.Field(p => p.Empleado).DefaultValue(
26.                ViewData["defaultEmpleado"] as Personal);
27.        })
28.    )
29.    .Scrollable(x => x.Height(300))
30.)

 

and here's the DropDownList template

1.@(Html.Kendo().DropDownListFor(m => m)
2.    .DataValueField("ID")
3.    .DataTextField("NumeroExpediente")
4.    .ValueTemplate("<span> #:data.NumeroExpediente# - #:data.Nombre# #:data.Apellido1# #:data.Apellido2#</span>")
5.    .Template("<span> #:data.NumeroExpediente# - #:data.Nombre# #:data.Apellido1# #:data.Apellido2#</span>")
6.    .BindTo((System.Collections.IEnumerable)ViewData["empleados"])
7.    .Filter(FilterType.StartsWith)
8.)

 

Here's a screenshot with the dropdownlist

https://www.dropbox.com/s/wddlfekt28ss8zg/dropDownList.png?dl=0

 

Thank you.

Viktor Tachev
Telerik team
 answered on 13 Jul 2017
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?