Telerik Forums
UI for ASP.NET MVC Forum
14 answers
2.0K+ views
So I've got a Kendo Grid populated by a view model.  All works fine when I am editing existing rows but when I try to add a new row I get a "Value cannot be NULL" error on my DropDownListFor control.  The property for the selected id of the dropdownlist is a string and it is a non-nullable field in the database.

Here is my code:

ViewModel:
public class ProposalTypeViewModel
{
    public decimal ID { get; set; }
    public string User_Facility_ID { get; set; }
    public string Code { get; set; }
    public string Description { get; set; }
    public bool Active { get; set; }
 
    public IEnumerable<SelectListItem> UserFacilities { get; set; }
}
UserFacilities is my list for the dropdownlist and User_Facility_ID would be the selected item.

Controller:
public ActionResult ProposalTypes()
{
    var context = new PASSEntities();
    User user = new User();
    int userID = user.GetUserIDByBNLAccount(User.Identity.Name);
 
    var model = (from a in context.Proposal_Types
                 join b in context.User_Facilities on a.User_Facility_ID equals b.ID
                 join c in context.Users_Roles on b.ID equals c.User_Facility_ID
                 join d in context.Users on c.User_ID equals d.ID
                 join e in context.Roles on c.Role_ID equals e.ID
                 where d.ID == userID && e.Name == "User_Facility_Admin"
                 select new ProposalTypeViewModel()
                 {
                     ID = a.ID,
                     User_Facility_ID = a.User_Facility_ID,
                     Code = a.Code,
                     Description = a.Description,
                     Active = a.Active,
                     UserFacilities = (from f in context.User_Facilities
                                       join g in context.Users_Roles on f.ID equals g.User_Facility_ID
                                       join h in context.Users on g.User_ID equals h.ID
                                       join i in context.Roles on g.Role_ID equals i.ID
                                       where h.ID == userID && i.Name == "User_Facility_Admin"
                                       select new SelectListItem
                                       {
                                           Text = f.ID,
                                           Value = f.ID
                                       })
                 });
    return View(model);
}
This is the Get method for the grid which populates the ViewModel.  I never get to the POST.  It throws the error as soon as I click the "Add New Record" button on the grid.

EditorTemplate:
@model PASSAdmin.ViewModels.UserFacilityAdmin.ProposalTypeViewModel
 
<div class="editor-label">
    @Html.Label("User Facility")
</div>
<div class="editor-field">
    @Html.DropDownListFor(model => model.User_Facility_ID,  new SelectList(Model.UserFacilities, "Value",  "Text"), "(Select One)")
    @Html.ValidationMessageFor(model => model.User_Facility_ID)
</div>
This is the DropDownListFor in my EditorTemplate being used on the grid.

I feel like I am missing something simple here...like somehow initializing the User_Facility_ID to an empty string or something so on a new record it doesn't have a null value which it is not allowed to have.   I have tried doing this in the ViewModel but unless I was doing it wrong it didn't help.
John
Top achievements
Rank 1
 answered on 03 Jan 2019
5 answers
466 views

Hello I would like to know if there is a way to add new tabs to a tab strip via a button that contain a kendo chat widget inside the tab?

I have seen examples of how to open new tabs with a button and I have also been able to have a chat widget inside of a tab but I cannot get them to work together.

Is this possible?

Plamen
Telerik team
 answered on 03 Jan 2019
5 answers
959 views

I have a grid in which the first column of the Grid is a drop down (ForeignKey column), while all other columns are readonly. Whenever user makes a selection, I want all the readonly columns be populated with relevant data against the selection made in the drop down column. For example: Drop down column is the Badge No of the employees, when user selects a badge #, I want first name, last name etc. populated for the selected badge # in other columns for that particular row only. How can I achieve this?

 

01.@(Html.Kendo().Grid<IMCC.TrainingTracker.Models.EmployeeMasterViewModel>()
02.    .Name("trainersGrid")
03.    .Columns(columns =>
04.    {
05.        columns.ForeignKey(c => c.emp_badge_no, (SelectList)(ViewBag.employees)).Width(90);
06.        columns.Bound(c => c.emp_first_name);
07.        columns.Bound(c => c.emp_last_name);
08.        columns.Bound(c => c.emp_company).Width(150);
09.        columns.Bound(c => c.emp_designation_text).Width(150);
10.        columns.Bound(c => c.emp_email_address).Width(120);
11.    })
12.    .Editable(editable => editable.Mode(GridEditMode.InCell))
13.    .ColumnMenu()
14.    .Pageable(p => p.Refresh(true).PageSizes(true))
15.    .Selectable(selectable =>
16.    {
17.        selectable.Mode(GridSelectionMode.Single);
18.            selectable.Type(GridSelectionType.Row);
19.    })
20.    .Sortable(sortable =>
21.    {
22.        sortable.SortMode(GridSortMode.MultipleColumn);
23.    })
24.    .Events(e => e.Edit("onEdit"))
25.    .Filterable()
26.    .Resizable(r => r.Columns(true))
27.    .Events(events =>
28.    {
29.        events.Change("onGridChange"); events.DataBound("onGridDataBound");
30.    })
31.        .DataSource(dataSource => dataSource
32.    .Ajax()
33.    .Model(model =>
34.    {
35.           model.Id(p => p.id);
36.        model.Field(p => p.emp_first_name).Editable(false);
37.        model.Field(p => p.emp_last_name).Editable(false);
38.        model.Field(p => p.emp_company).Editable(false);
39.        model.Field(p => p.emp_designation_text).Editable(false);
40.        model.Field(p => p.emp_email_address).Editable(false);
41.    })
42.    .Read(read => read.Action("CourseTrainers_Read", "CourseTrainer").Data("GetCurrentCourse"))
43.                    Update(update => update.Action("CourseMaster_Update", "CourseMaster"))
44.                    .Destroy(destroy => destroy.Action("CourseMaster_Destroy", "CourseMaster"))
45.            )
46.)
Alex Hajigeorgieva
Telerik team
 answered on 02 Jan 2019
1 answer
4.6K+ views

Several fields are configured as not editable and working as designed except for:

- ReportCategoryDesc  (Text field)

- IsVisibleInMenu           (Boolean)

Any ideas why these 2 are still editable?

Thanks

 

 

@( Html.Kendo().Grid<ShelfLife.ViewModels.Telerik.ReportMaintenanceItemVM>()
        .Name("client")
        .Columns(columns =>
        {
            columns.Bound(c => c.ReportID).Width(70).Title("ID");
            columns.Bound(c => c.ReportTitle);
            columns.Bound(c => c.ReportDescription);
            columns.Bound(c => c.Categories.ReportCategoryDesc).Filterable(ftb => ftb.Multi(true).Search(true));
            columns.Bound(c => c.ReportOrder).Width(100).Title("Order");
            columns.Bound(c => c.TRDXFile);
            columns.Bound(c => c.IsVisibleInMenu).Width(130).ClientTemplate("<input type='checkbox' #= IsVisibleInMenu ? checked='checked' :'' # />");
            columns.Bound(c => c.Active).Width(120).ClientTemplate("<input type='checkbox' #= Active ? checked='checked' :'' # />"); ;
            columns.Command(command => command.Destroy()).Width(110);
        })
        .ToolBar(toolbar =>
        {
            toolbar.Create();
            toolbar.Save();
        })
        .HtmlAttributes(new { style = "height: 900px;" })
        .Editable(editable => editable.Mode(GridEditMode.InCell))
        .Filterable()
        .Pageable(pageable => pageable.PageSizes(new int[] { 10, 20, 50, 100, 999 }))
        .ColumnMenu()
        .Groupable()
        .Navigatable()
        .Sortable()
        .Scrollable(scr => scr.Height(900))
        .DataSource(dataSource => dataSource
            .Ajax()
            .Batch(true)
            .PageSize(20)
            .ServerOperation(false)
            .Events(events => events.Error("error_handler"))
            //.Model(model => model.Id(p => p.ReportID))
            .Model(model => {
                model.Id(p => p.ReportID);
                model.Field(p => p.ReportID).Editable(false);
                model.Field(p => p.ReportCategoryID).Editable(false);
                model.Field(p => p.ReportCategoryDesc).Editable(false);
                model.Field(p => p.ReportDescription).Editable(false);
                model.Field(p => p.ReportOrder).Editable(false);
                model.Field(p => p.ReportTitle).Editable(false);
                model.Field(p => p.TRDXFile).Editable(false);
                model.Field(p => p.IsVisibleInMenu).Editable(false);
            })

        .Create("Filter_Multi_Editing_Create", "Telerik")
        .Read("Filter_Multi_Editing_Read", "Telerik")
        .Update("Filter_Multi_Editing_Update", "Telerik")
        .Destroy("Filter_Multi_Editing_Destroy", "Telerik")
        )
    )

John
Top achievements
Rank 1
 answered on 31 Dec 2018
2 answers
295 views

I am using MultiColumnComboBox in my application which binds to the datasource correctly but when I click the dropdown button, the list does not render properly. All the data shows in one column. The column headings render properly though.

<div class="col-md-6 col-sm-12" style="margin-top:10px">
     @(Html.Kendo().MultiColumnComboBoxFor(model=>model.Trainers)
        .Name("trainersCombo")
        .DataTextField("emp_badge_no")
        .DataValueField("id")
        .Filter("contains")
        .FilterFields(new string[] { "emp_first_name", "emp_last_name", "emp_company" })
        .Columns(columns =>
        {
            columns.Add().Field("emp_badge_no").Title("Badge No").Width(100);
            columns.Add().Field("emp_company").Title("Company").Width(200);
            columns.Add().Field("emp_first_name").Title("First Name").Width(200);
            columns.Add().Field("emp_last_name").Title("Last Name").Width(100);
         
        })
        .FooterTemplate("Total #: instance.dataSource.total() # items found")
        .HtmlAttributes(new { style = "width:100%;" })
        .Height(400)
        .DataSource(source => source
                .Custom()
                .Transport(transport => transport
                .Read(read =>
                {
                    read.Action("GetAllEmployees", "CourseTrainer").Data("onAdditionalData");
                }))
            )
    )
</div>

and here is the code for GetAllEmployees

public JsonResult GetAllEmployees(string badgeNo)
        {
            var items = db.EmployeeMasters.AsQueryable();
 
            if (!string.IsNullOrWhiteSpace(badgeNo))
            {
                items = items.Where(p => p.emp_badge_no == badgeNo);
            }
 
            var data = items.Select(p => new { p.id, p.emp_badge_no, p.emp_first_name, p.emp_last_name, p.emp_company });
            return Json(data, JsonRequestBehavior.AllowGet);
        }

I have 2018.3.1017.545 version of Kendo.mvc.dll. Below image shows how the data is render in the drop down.

 

Wasim
Top achievements
Rank 1
 answered on 30 Dec 2018
1 answer
422 views

Hi

I have issue with Kendo treeview expanding in my MVC project. I try to expand treeview node (which have children nodes) at same time when I select it. The code went through in .js file without error.  but node didn't expand. Could any one tell me what properly be wrong? below are piece of code.  Thanks.

 

        var selectedNode = $("#treeView").data('kendoTreeView').dataItem(e.node); // selectedNode have correct data after this.
        var treeView = $("#treeView").data('kendoTreeView');
        treeView .expand(selectedNode); //Code went through without error

 

 

Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
 answered on 28 Dec 2018
1 answer
203 views

Currently evaluating the Upload control, I ideally want only a simple upload button to select local files and do everyting else on my own through the client API.

Especially the gray div (k-widget k-upload k-header) around the button bothers me.

 

My question:

Is it possible to tell the Upload control to simply display the core upload button and omit everything else, even after the user has selected files?

Marin Bratanov
Telerik team
 answered on 26 Dec 2018
3 answers
1.0K+ views

Is there a way to get the responsive behavior for the menu to change to a hamburger menu when the screen size is small? I saw this older post and was wonder if anything has changed.

https://www.telerik.com/forums/menu-and-bootstrap

The behavior would be similar to http://getbootstrap.com/examples/navbar/

Thanks

Ivan Zhekov
Telerik team
 answered on 24 Dec 2018
3 answers
1.5K+ views

I've a grid with ajax binding and exports to excel/PDF fine when dealing with less than a thousand records. But when I want to export bigger quantities the grid doesn't do anything at all. I even put breakpoints in both export actions with no luck.

What can I do to solve this issue?

This is my grid:

<script src="~/Scripts/lib/jszip.min.js" type="text/javascript"></script>
<script src="~/Scripts/lib/pako.js" type="text/javascript"></script>
<script src="~/Scripts/KendoUI/ExportPDFCustomizing.js" type="text/javascript"></script>

@(Html.Kendo().Grid(Model)
        .Name("OperacionesDelDia")
        .DataSource(dataSource => dataSource
        .Ajax()
            .Read(read => read.Action("OperacionesDelDia_Read", "Operaciones")
            .Data("PasarParametros"))
        .Aggregates(a =>
            {
                a.Add(p => p.oper_monto).Sum();
                a.Add(p => p.oper_mont_neg).Sum();
            })
        .PageSize(30)
        )
        .Columns(columns =>
        {
            columns.Bound(foo => foo.esto_codigo).Title(Global.Estado);
            columns.Bound(foo => foo.oper_numero)
                .Title(Global.Numero)
                .ClientTemplate("<a onclick=\"showDetails('#= oper_numero #')\" href='\\#'>#= oper_numero #</a>");            
            columns.Bound(foo => foo.merc_codigo).Title(Global.Mercado);
            columns.Bound(foo => foo.oper_nrobol).Title(Global.Boleto);
            columns.Bound(foo => foo.clas_codigo).Title(Global.Clase);
            columns.Bound(foo => foo.tope_codigo).Title(Global.TipoOperacion);
            columns.Bound(foo => foo.ClieNombre).Title(Global.RazonSocial);
            columns.Bound(foo => foo.espe_codigo).Title(Global.Especie);
            columns.Bound(foo => foo.cupo_numero).Title(Global.Cupon).Hidden(true);
            columns.Bound(foo => foo.clie_alias).Title(Global.ClienteAlias).Hidden(true);
            columns.Bound(foo => foo.oper_forigen).Title(Global.FechaOrigen).Format("{0:dd/MM/yyyy}");
            columns.Bound(foo => foo.oper_plazo).Title(Global.Plazo).Hidden(true);
            columns.Bound(foo => foo.oper_fvence).Title(Global.FechaVence).Format("{0:dd/MM/yyyy}");
            columns.Bound(foo => foo.oper_monto).Title(Global.Capital).Format("{0:N}").ClientFooterTemplate("#= kendo.format('{0:N}', sum)#");
            columns.Bound(foo => foo.espe_codcot).Title(Global.EspecieNeg).Hidden(true);
            columns.Bound(foo => foo.oper_tna).Title(Global.Tna);
            columns.Bound(foo => foo.oper_interes).Title(Global.Interes).Hidden(true);
            columns.Bound(foo => foo.oper_mont_neg).Title(Global.Monto).Format("{0:N}").ClientFooterTemplate("#= kendo.format('{0:N}', sum)#");
            columns.Bound(foo => foo.clie_cuit).Title(Global.Cuit).Hidden(true);
            columns.Bound(foo => foo.TipoNroDoc).Title(Global.TipoNroDoc).Hidden(true);
            columns.Bound(foo => foo.usua_codigo).Title(Global.Usuario);
            columns.Bound(foo => foo.usua_alta).Title(Global.UsuarioAlta).Hidden(true);
            columns.Bound(foo => foo.oper_falta).Title(Global.FechaAlta).Format("{0:dd/MM/yyyy}").Hidden(true);
            columns.Bound(foo => foo.liquidada).Title(Global.Liquidado).Hidden(true);
            columns.Bound(foo => foo.usua_surperv).Title(Global.UsuarioSuperv).Hidden(true); 
            columns.Bound(foo => foo.oper_nombre).Title(Global.Operador).Hidden(true); 
            columns.Bound(foo => foo.oper_observ).Title(Global.Observaciones).Hidden(true); 
            columns.Bound(foo => foo.espedesc).Title(Global.EspecieDesc).Hidden(true); 
            columns.Bound(foo => foo.orden_numero).Title(Global.Orden).Hidden(true);
        })
        .Excel(excel => excel
            .FileName("Reporte.xlsx")
            .Filterable(true)
            .AllPages(true)
            .ProxyURL(Url.Action("Excel_Export_Save", "Operaciones"))
        )
            
        .Pdf(pdf => pdf
            .PaperSize("A4")
            .AllPages()
            .Landscape()
            .FileName("Reporte.pdf")
            .ProxyURL(Url.Action("Pdf_Export_Save", "Operaciones"))
        )

        .Events(e => e.PdfExport("ExportarPDF"))
        .ToolBar(t => t.Excel().Text("Exportar a Excel"))
        .ToolBar(t => t.Pdf().Text("Exportar a PDF"))
        .ColumnMenu()
        .Pageable()
        .Sortable()
        .Selectable()
        .Scrollable(s => s.Height(320))
        .Groupable()
        .Resizable(resize => resize.Columns(true))
        .Reorderable(reorder => reorder.Columns(true))
        .Filterable(ftb => ftb.Mode(GridFilterMode.Menu))
    )

<script type="text/javascript">

function PasarParametros() {

        var dpFechaDesde = $("#fechaDesde").data("kendoDatePicker");
        var valorFechaDesde = dpFechaDesde.element[0].value;

        var dpFechaHasta = $("#fechaHasta").data("kendoDatePicker");
        var valorFechaHasta = dpFechaHasta.element[0].value;

        var ddlLiquidadas = $("#liquidadas").data("kendoDropDownList");
        var valorLiquidadas = ddlLiquidadas.element[0].value

        return {
            fechaDesde: valorFechaDesde,
            fechaHasta: valorFechaHasta,
            liquidadas: valorLiquidadas
        };
    }
</script>

 

And these are my actions:

 

[HttpPost]
public ActionResult Excel_Export_Save(string contentType, string base64, string fileName)

        {
            var fileContents = Convert.FromBase64String(base64);

            return File(fileContents, contentType, fileName);
        }

        [HttpPost]
        public ActionResult Pdf_Export_Save(string contentType, string base64, string fileName)
        {
            var fileContents = Convert.FromBase64String(base64);

            return File(fileContents, contentType, fileName);
        }

 

Thank you very much

Preslav
Telerik team
 answered on 24 Dec 2018
1 answer
289 views

When working with the .Group property, there is an option for changing the sort.

.Group(group => group.Add(p => p.fieldname))

it would appear that you should be able to set the System.ComponentModel.ListSortDirection

This is not working, and the documentation is abysmal.

Instead of the group sorting asc, I need it to sort desc.

 

 

 

 

Georgi
Telerik team
 answered on 21 Dec 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
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
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?