Telerik Forums
UI for ASP.NET MVC Forum
1 answer
109 views

Ho Do I tranform this code in the @(Html.Kendo()) razor mvc style?

 

$("#grid").data("kendoGrid").dataSource.filter({
field: "date",
//create custom filter operator
operator: function(fieldDate) {

var parsedSelectedDate = kendo.parseDate(selectedDate);
//parse the field date in order to ignore the time
var parsedFieldDate = new Date(fieldDate.getFullYear(),  fieldDate.getMonth(), fieldDate.getDate());
var result = (parsedFieldDate.getTime() == parsedSelectedDate.getTime());

return result;

},
value: selectedDate
});

 

Eyup
Telerik team
 answered on 27 Oct 2020
1 answer
174 views

I came accross this code that I need to implemente on my numeric column in a grid that uses popup editor:

...

columns: ["ProductName",{ field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: 120,editor: editNumber },{ field: "Discontinued", width: 120, editor: customBoolEditor },{ command: "destroy", title: " ", width: 150 }], editable: true});});

...

 

How can I do the same in the razor selector, ex:

 

columns.Bound(c=>c.UnitPrice).Title("Unit Price").???

 

thanks

 

Eyup
Telerik team
 answered on 27 Oct 2020
9 answers
1.4K+ views

Hi,

I have created a Telerik MVC Grid as follows. I have binded Datatable to the grid as the number of columns vary time to time. So, I cannot use the in-build CRUD methods.

1. Can you please help me how to proceed?

2. Also I have tried using Client Template and it throws exception "System.InvalidOperationException: Child actions are not allowed to perform redirect actions." 

I have gone through the 

 @(Html.Kendo().Grid(Model.Department).Name("Model.Department")
        .Columns(col =>
        {
        foreach (System.Data.DataColumn column in Model.Department.Columns)
        {
           if (column.ColumnName != "DEPTID")
                col.Bound(column.ColumnName).EditorTemplateName("string");
        }

        col.Template(@<text></text>).ClientTemplate(Html.ActionLink("Delete","DeleteDepartment",new {id = "#=DEPTID#"}).ToHtmlString());
        })
        .ToolBar(toolbar =>
        {
            toolbar.Save();
        })
        .Pageable()
        .Sortable()
        .Editable(ed => ed.Mode(GridEditMode.InCell))
        .Filterable()
        .DataSource(dataSource => dataSource
            .Ajax()
            .Batch(true)
            .ServerOperation(true)
            .Model(model =>
            {
                var id = Model.Department.PrimaryKey[0].ColumnName;
                model.Id(id);
                foreach (System.Data.DataColumn column in Model.Department.Columns)
                {
                    var field = model.Field(column.ColumnName, column.DataType);
                    if (column.ColumnName == id)
                    {
                        field.Editable(false);
                    }

                }
            })
            .Create("CreateDepartment", "Administration")
            .Read("GetDepartments", "Administration")
            .Update("UpdateDepartment", "Administration")
        ))

I

Danny
Top achievements
Rank 1
Iron
Veteran
Iron
 answered on 26 Oct 2020
11 answers
3.5K+ views
The grid looks correct in display mode but when I switch to edit mode the textbox is too narrow.

How can I set the width?

I included a screenshot, just in case I'm not clear.
Jennifer
Top achievements
Rank 1
 answered on 26 Oct 2020
3 answers
106 views

Hello there,

I made a button for the Scheduler grouping,

So if I group the scheduler, the left border line will disappear (Screenshot 2020-09-16 142154_LI.jpg)

Then i looked if this disappearing has something to do with the CSS classes ! and i found this (Class_agenda.png)

is there any purpose behind this ? or is it just the wrong class in the wrong View and i should remove it ? :-)

 

Thanks in advance

Blackout

Dimitar
Telerik team
 answered on 26 Oct 2020
3 answers
132 views

Hi, i have this code, everything work good except the search panel. I miss something?

@(Html.Kendo().Grid<GestionLaboratorio.Models.BD_HCE.LAB_GetContenedorOpenLab_Result>()
                                .Name("gridOpenLab")
                                .Columns(columns =>
                                {
                                    columns.Bound(p => p.id).Title("ID").Width(100);
                                    columns.Bound(p => p.nombre).Title("Descripcion");
                                    columns.Bound(p => p.abreviatura).Title("Abreviatura").HtmlAttributes(new { style = "text-align: center;" }).HeaderHtmlAttributes(new { style = "text-align: center;" });
                                    columns.Bound(p => p.tipoImpresion).Title("Tipo de impresion").EditorTemplateName("TipoImpresionOpenLab").ClientTemplate("#:DescTipoImpr#").HeaderHtmlAttributes(new { style = "text-align: center;" });
                                    columns.Command(command => { command.Edit().Text(" ").CancelText(" ").UpdateText(" "); command.Destroy().Text(" "); }).Width(150).HtmlAttributes(new { style = "text-align: center;" });
                                })
                                .Editable(editable => editable.Mode(GridEditMode.InLine))
                                .ToolBar(t => t.Search())
                                .Pageable()
                                .Sortable()
                                .Scrollable()
                                .HtmlAttributes(new { style = "height: 500px;" })
                                .DataSource(dataSource => dataSource
                                    .Ajax()
                                    .PageSize(8)
                                    .Events(events => events.Error("error_handler"))
                                    .Model(model =>
                                    {
                                        model.Id(f => f.id);
                                    })
                                    .Read(read => read.Action("Get_Contenedor_OpenLab", "OpenLab"))
                                    .Update(update => update.Action("Update_Contenedor_OpenLab", "OpenLab"))
                                    .Destroy(destroy => destroy.Action("Delete_Contenedor_OpenLab", "OpenLab"))
                                )
                                .Events(events => events.Save("contenedorGuardado_Save"))
                                .Resizable(resize => resize.Columns(true))

 

public ActionResult Get_Contenedor_OpenLab([DataSourceRequest]DataSourceRequest request)
        {
            try
            {
                return Json(bd_hce_lab.LAB_GetContenedorOpenLab().ToList().ToDataSourceResult(request));
            }
            catch (Exception e)
            {
                return Json(null);
            }
        }

 

 

 

 

Nikolay
Telerik team
 answered on 26 Oct 2020
1 answer
1.3K+ views

I have multiple KendoUpload control in my page and I have a custom submit button. By clicking submit whichever upload control having data those to be submitted to dot net core controller part. I am good to submit one KendoUpload value, but not able to pass multiple upload values into controller part at one shot.
I am also passing other input values along with upload file. This is a single upload process, I am following. In the controller part, I am receiving by IFormFile.
Any suggestion?

public async Task<IActionResult> UploadImage(IEnumerable<IFormFile> files, ReportComponentVM subVM)
        {
            try
            {
                if (files != null)
                {
                    await AttachmentFileSave(false, files.FirstOrDefault(), "test", "test2",1);
                }
                return Json(new JsonResponse { Message = "UploadImage", IsSuccess = true });
            }
            catch (Exception ex)
            {
                return Json(new JsonResponse { Message = ex.Message, IsSuccess = false });
            }
        }
Aleksandar
Telerik team
 answered on 26 Oct 2020
9 answers
2.2K+ views
Hi, 

I have the same issue as reported on the old Telerik MVC forum:

http://www.telerik.com/community/forums/aspnet-mvc/upload/multiple-upload-controls-in-grid-do-not-work.aspx

except i am not using a grid. I dynamically add "widgets" to a view each with an upload control. The first widget works fine as the name is unique but subsequent widgets do not render as the name/id is duplicated. Using the mvc wrapper as so:
@(Html.Kendo().Upload()
    .Name("CreateMediaSelect")
    .Async(a => a
        .Save("MyActionName", "ControllerName")
        .AutoUpload(true)
    )
    .Events(events => events
        .Success("OnSuccess")
        .Upload("OnUpload")
    )
)
public ActionResult MyActionName(IEnumerable<HttpPostedFileBase> CreateMediaSelect)

I can change the name/ID on each widget e.g. CreateMediaSelect_0 but as in the above post, there is an unlimited number of these. How to keep the one action in the controller, but have multiple upload controls?

Has the fix explained in the Telerik solution been ported to Kendo? I tried a third argument in the overload to no avail.

Thanks.
Aleksandar
Telerik team
 answered on 26 Oct 2020
1 answer
555 views

Using some examples I see in this forum, I am just trying to create a simple modal window on the fly via javascript.  This is called from a JS function to create and open a new window that I can then refresh the content via an ajax post call.   The line var win=... I get win = undefined.  Clearly I'm missing something basic?

$('#windowX').kendoWindow({
    width: "900px",
    height: "500px",
    title: "Add Temp Node",
    visible: true,
    modal: true,
    resizable: true,
    actions: ["Close"],
}).data('kendoWindow');
 
 
var win = $('#windowX').data('kendoWindow');
win.center().open();
Ivan Danchev
Telerik team
 answered on 23 Oct 2020
4 answers
1.0K+ views

Hi,

I have a problem while loading data to a grid. I want to disable Pagination and show all data on one page.

 

@(Html.Kendo().Grid<WasteGridViewModel>()
      .Name("gridAllWaste")
      .Columns(columns =>
      {
          columns.Bound(c => c.LocationCode).Title(@Helpers.Localize("gridLabel_locationCode").ToString());
          columns.Bound(c => c.Timestamp).Format("{0:dd-MM-yyyy}").Title(@Helpers.Localize("gridLabel_timestamp").ToString());
          columns.Bound(c => c.Value).Title(@Helpers.Localize("gridLabel_value").ToString());          
          if (User.Identity.IsInRole(UserRole.EditWaste))
          {
              columns.Command(command =>
              {
                  command.Edit().Text(@Helpers.Localize("edit").ToString());
                  if (User.Identity.IsInRole(UserRole.AllAccess))
                  {
                      command.Custom(@Helpers.Localize("delete").ToString()).Click("openWindow");
                  }
              }).Width(250);
          }
 
      })
      .ToolBar(toolbar =>
      {
          if (User.Identity.IsInRole(UserRole.EditWaste))
          {
              toolbar.Create().Text(@Helpers.Localize("wasteGrid_add").ToString());
          }
      })
      .Scrollable(s => s.Height("auto"))
      .Groupable()
      .Sortable()
      .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("WasteEdit").DisplayDeleteConfirmation(false))
      .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
      .Pageable(pageable => pageable
          .Refresh(true)
          .PageSizes(true)
          .ButtonCount(5))
      .DataSource(dataSource => dataSource
          .Ajax()
          .PageSize(50)
          .Events(events =>
          {
              events.Error("errorHandler");
              events.RequestEnd("onRequestEnd");
 
          })
          .Model(model => model.Id(p => p.WasteId))
          .Read(read => read.Action("GetAllWaste", "Waste"))
          .Create(update => update.Action("CreateWaste", "Waste"))
          .Update(update => update.Action("UpdateWaste", "Waste"))
          .Destroy(update => update.Action("DeleteWaste", "Waste"))
      ))

 

Above code works fine, but when I remove Pageable and change PageSize to bigger number, for example 6000 grid doesn't show any data. I get respone 302 on my request:

Request URL:http://localhost:29786/Waste/GetAllWaste
Request Method:POST
Status Code:302 Found
Remote Address:[::1]:29786
Referrer Policy:no-referrer-when-downgrade
Repose Headers:
Cache-Control:private, s-maxage=0
Content-Length:157
Content-Type:application/json; charset=utf-8
Date:Tue, 20 Jun 2017 09:04:53 GMT
Location:/Error/?aspxerrorpath=/Waste/GetAllWaste
Server:Microsoft-IIS/10.0
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:5.2
X-Powered-By:ASP.NET
X-SourceFiles:=?UTF-8?B?QzpcUmVwb3NpdG9yaWVzXFdhc3RlXHNyY1xFbmdpZS5XYXN0ZVxFbmdpZS5XYXN0ZVxXYXN0ZVxHZXRBbGxXYXN0ZQ==?=

 

Thanks in advance for any help.

Viktor Tachev
Telerik team
 answered on 23 Oct 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
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?