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

I'm trying to implement filter checkboxes with my dynamic column grid. I return a List<string> of options that I retrieve based on the PropertyName that I pass to the read action of the Filterable property.

I keep getting the following javascript error, where X33 is the generic column name that is mapped to the actual data column. Any advice would be great.

VM2049:3 Uncaught ReferenceError: X33 is not defined
    at eval (eval at compile (kendo.all.min.js:25), <anonymous>:3:209)
    at Object.render (kendo.all.min.js:25)
    at Object.d [as render] (jquery.min.js:2)
    at init.createCheckBoxes (kendo.all.min.js:43)
    at init.refresh (kendo.all.min.js:43)
    at init.options.forceUnique.checkChangeHandler (kendo.all.min.js:43)
    at init.trigger (kendo.all.min.js:25)
    at init._process (kendo.all.min.js:28)
    at init.success (kendo.all.min.js:27)
    at success (kendo.all.min.js:27)
 

Here is the relevant code for setting up the columns.

foreach (ColumnSettings col in Model.GridColumns)
{
     columns.Bound(col.PropertyName).Title(col.Title).Width(col.Width).Filterable(ftb => ftb.Multi(true)
         .DataSource(ds => ds.Read(r => r.Action("Unique", "Data").Data("{ field: '" + col.PropertyName + "' }"))));
}

 

Preslav
Telerik team
 answered on 22 May 2017
16 answers
2.8K+ views
Hello,

I've added a custom command, "Details", to the rows in my grid so a user can view the details about the row.  When clicked, I want it to access the Details action in my HomeController.  However, when I build my solution, I receive the following error message:

"Custom command routes is available only for server binding."

Can someone please tell me how I can correct this issue?  My ulitimate goal is to create custom command buttons for Add, Edit, Delete, and Details, so my existing Views will be presented, rather than using the inline editing.  I need to create these custom buttons because the default command buttons don't seem to permit routing to my Views.  Anyway, I would appreciate your help.

Thanks,
Mike

      .Columns(columns =>
      {
          columns.Command(p => { p.Custom("ViewDetails").Action("Details", "Home").Text("Details"); }).Width(160);
          columns.Bound(p => p.CustomerId)
      })
Boyan Dimitrov
Telerik team
 answered on 22 May 2017
1 answer
204 views
Anyone know how I can get my grid to auto expand it's width when the browser width changes? I have two grids left and right of each other. I would like the left grid to auto size it's width and the right grid to be 400px. I can't seem to do this. I tried setting the right grid to float:right and it's always wrapping down to the bottom. The ultimate goal is to have the right grid disappear if the browser width is less than 768px. For that I was going to use the responsive web control, but first I think I need the left grid to auto size properly. Then if the right grid disappears the left grid will fill the remaining space. Any ideas would be greatly appreciated!
Stefan
Telerik team
 answered on 22 May 2017
2 answers
144 views

Hello, as the title says, I'm trying to add a vertical splitter to the right side of a grid - there's a functionality on the right of the grid which allows users to show listed details, and I want to allow them to decrease the size of the grid.

Unfortunately, that's the second day I'm battling this issue and it doesn't seem anyone was facing this problem on MVC - only I saw a similar AJAX problem.

I attached a schematic view of what I'm trying to achieve. Thanks in advance for any help.

 

 

Alex Hajigeorgieva
Telerik team
 answered on 22 May 2017
4 answers
161 views

Hello

I'm almost ending a project development that includes MVC 2017.1.233 ( Feb 23 2017)
If I just update to 2017.2.504 (May 4 2017) will I need to update the source code to make the application work with this new version ?
Only the DLL should be updated?  js and css too?
Best regards and tank you.

Stefan
Telerik team
 answered on 22 May 2017
10 answers
1.0K+ views

I am trying to use the Kendo Grid in an Angular controller.  The DataSource posts to an MVC Controller.  I need to send the data collected from the user in the form as well as the DataSourceRequst to the MVC Controller.  My dataSource for the grid in the Angular controller looks like this:

dataSource: new kendo.data.DataSource({
                type: "aspnetmvc-ajax",
                transport: {
                    read: {
                        url: "/SSQV4/SSQV5/Search/SubmitCriteria",
                        data: { form: $scope.form }
                    }
                },
                schema: {
                    data: "Data",
                    total: "Total"
                },
                pageSize: 25,
                serverPaging: true,
                serverFiltering: true,
                serverSorting: true
            }),

The method in the MVC Controller looks like this:

        public async Task<ActionResult> SubmitCriteria([DataSourceRequest]DataSourceRequest command, ContractorSearchViewModel form)

The problem is that is the values in $scope.form are set using ng-model on any inputs like <input type="text" ng-model="form.UnitID">, although it shows a value in $scope.form.UnitID in the Angular controller, when it reaches the MVC controller it is null.  However, if instead of setting it from ng-model in an input, I set it manually in the Angular controller like $scope.form.UnitID = "123", then when the dataSource hits the MVC Controller, UnitID has value and is not null.  I can I fix this?  I need all of the information in the DataSourceRequest object as well as all of the information in the $scope.form object to get to my MVC Controller.

I also tried using a service like below:

             transport: {

                  read: function (e) {
                      generalsearchService.submitSearch(e.data, form)
                          .then(function success(response) {
                              e.success(response.data);
                          });
                  }
              },

When this hits the MVC controller, "form" is completely populated as desired, but e.data is missing the "filtering" and "sorting" which are null.  It only contains page and pageSize.  This has been a very frustrating process.  Any assistance is greatly appreciated!

Beryl
Top achievements
Rank 1
 answered on 19 May 2017
2 answers
207 views

Hello,

 

I have implemented the upload success and error template from this demo http://demos.telerik.com/aspnet-mvc/notification/templates.

I am trying to display the error template if one of three fields in the pop up template are not valid otherwise the success one.

I think it is a problem about the k-invalid class being applied to a different DOM element but I am not sure.

This boolean var invalid = (startDateField.hasClass("k-invalid") || endDateField.hasClass("k-invalid") || entitlementField.hasClass("k-invalid")) is still false even one or more of the fields have the class k-invalid

I have put in attachments the files required.

Thanks you

 

Sean
Top achievements
Rank 1
 answered on 19 May 2017
1 answer
7.2K+ views

I have a dialog that has two linked listboxes:

@(Html.Kendo().Dialog()
        .Name("dlgEdit")
        .Title("Edit Batch")
        .Content("<div style='display: flex; flex-direction:row; align-content:flex-start; align-items:stretch;' style='width:100%;'>" +
            "<div style='display: flex; flex-direction: column; align-content:flex-start; width:48%; margin-right: 8px;'>" +
            "<h3>Department Keys</h3>" +
            "<div><input id='editSearch' type='text' placeholder='Search department keys' style='height: 28px; margin: 0; padding: 0;' onkeyup='filterDepts()'/>" +
            "<img src='" + @Url.Content("~/Images/x-mark.png") + "' style='width: 12px; margin-left: 4px; cursor: pointer;' onclick='filterClear()' /></div>" +
            Html.Kendo().ListBox()
                .Name("optional")
                .DataValueField("Value")
                .DataTextField("Text")
                .DataSource(source => source
                    .Custom()
                    .Transport(transport => transport
                        .Read(read => read
                            .Action("GetDepartments", "CouncilReport")
                        )
                    )
                )
                .DropSources("selected")
                .BindTo(new List<SelectListItem>())
                .Draggable(true)
                .Selectable(ListBoxSelectable.Single)
                .HtmlAttributes(new { title = "Department Keys", style = "flex: 1; width: 100%; margin-top: 8px;" })
                .ConnectWith("selected") + "</div>" +
            "<div style='flex: 1; display: flex; flex-direction: column; align-content:flex-start; padding: 0;'>" +
            "<h3>Batch Details</h3>" +
            "<form id='editForm'>" +
            "<input id='editDesc' type='text' placeholder='Batch name' style='height: 28px; margin: 0; padding: 0;' />" +
            "<input id='editId' type='hidden' />" +
            Html.Kendo().ListBox()
                .Name("selected")
                .DataValueField("Value")
                .DataTextField("Text")
                .Draggable(true)
                .DataSource(source => source
                    .Custom()
                    .Transport(transport => transport
                        .Read(read => read
                            .Action("GetBatchDepts", "CouncilReport")
                    )
                )
            )
            .DropSources("optional")
            .ConnectWith("optional")
            .HtmlAttributes(new { title = "Selected Keys", style = "width: 100%; height: 500px; margin-top: 8px;" })
            .BindTo(new List<SelectListItem>())
            .Selectable(ListBoxSelectable.Single) +
        "</form></div></div></div>"
    )
    .Width(1000)
    .Modal(true)
    .Visible(false)
    .Actions(actions =>
    {
        actions.Add().Text("Cancel");
        actions.Add().Text("OK").Primary(true).Action("onOkEdit");
    })
)

When I open the dialog I call a read() to reset the listboxes for the selected batch:

        var treeview = $("#treeview").data("kendoTreeView");
        var selected = treeview.select();
        var data = treeview.dataItem(selected);

        $("#editSearch").val("");
        $("#editId").val(data.id);
        $("#editDesc").val(data.Description);
        var opt = $("#optional").data("kendoListBox");
        var sct = $("#selected").data("kendoListBox");
        sct.dataSource.read();
        opt.dataSource.read({ id: data.id });
        $("#dlgEdit").data("kendoDialog").open();

Notice that I am passing the id into the read() method at this line:

opt.dataSource.read({ id: data.id });

I must not have something right because the parameter is never used and I get an error 500 from the server because there was no parameter passed to the action "GetBatchDepts".

Can someone please help me see what I am doing wrong?

 

 

Marion
Top achievements
Rank 1
 answered on 19 May 2017
1 answer
301 views

I attached a file for testing the case. It's related to Kendo Date Pickers using Bootstrap modals in an MVC architecture.

First, I've included 2 datePickers. They work as expected. No problems related to using multiple controls. It also means all styles and scripts are loaded fine.

But when I add a third control in a Bootstrap modal, it looks completely different.
When analyzing the DOM, this control is rendered as a text input with the right date, but... No possibilities to use the selector that should appear as a pop up.

Thanks in advance for any help.

Stefan
Telerik team
 answered on 19 May 2017
2 answers
634 views

Hi, below please see my view I'm having issues with.  I'm trying to check for a successful save (my items are being saved out to the database correctly, so I have no reason to believe there's an issue with the save) but as you can see in the "wasSaveSuccessful" function, I'm alerting out the e.type.  The initial read alerts out "read" as expected, but after changes (done with a template column with radio buttons) it alerts out "undefined".  Not sure why, but is there another way to check for success?  I want to pop down a notification to the users when their changes have been successful.

 

<div class="col-lg-12 column">
    <div class="row page-header">
        <h1>
            Metric Threshold Maintenance <small>Edit Metric Threshold Values</small>
        </h1>
    </div>
    <div class="col-lg-3">
        @(Html.Kendo().TreeView()
            .Name("ProgramTree")
            .DataTextField("Name")
            .Events(e => e.Change("programSelected"))
            .DataSource(dataSource => dataSource.
                Read(read => read.Action("Traceables_Read", "ProgramView"))
            )
            .Animation(true)
        )
    </div>
 
    <div class="col-lg-9">
        @(Html.Kendo().Grid<HVMS.BusinessLayer.Models.Metric>()
      .Name("MetricGrid")
      .Events(e =>
      {
          e.DataBound("onDataBound");
      })
      .Columns(columns =>
      {
 
          columns.Bound(c => c.Name);
          columns.Bound(c => c.ThresholdAssignment).ClientTemplate(
              "#=dirtyField(data,'ThresholdAssignment')#<div onClick='stopEditing(event,this)'><input type='radio' name='Metrics[#= index(data)#].ThresholdAssignment' value='Unassigned' # if (ThresholdAssignment == 0) { # checked = 'checked' # } # /> <span>Unassigned</span>" +
              "  <input type='radio' name='Metrics[#= index(data)#].ThresholdAssignment' value='Weekly'  # if (ThresholdAssignment == 1) { # checked = 'checked' # } # /> <span>Weekly</span>" +
              "  <input type='radio' name='Metrics[#= index(data)#].ThresholdAssignment' value='Monthly' # if (ThresholdAssignment == 2) { # checked = 'checked' # } # /> <span>Monthly</span></div>"
              );
 
 
      })
      .ToolBar(toolbar =>
      {
          toolbar.Save();
          toolbar.Excel();
          toolbar.Pdf();
      })
      .Editable(editable => editable.Mode(GridEditMode.InCell))
      .Navigatable()
      .Scrollable(s => s.Height("auto"))
      .Selectable(selectable => selectable
            .Mode(GridSelectionMode.Single)
            .Type(GridSelectionType.Row))
      .AutoBind(false)
      .DataSource(dataSource => dataSource
          .Ajax()
          .Batch(true)
          .Model(model =>
          {
              model.Id(p => p.Id);
              model.Field(p => p.Name).Editable(false);
          })
          .Read(read => read.Action("Metrics_Read", "MetricThreshold").Data("additionalData"))
          .Update(update => update.Action("Metrics_Update", "MetricThreshold"))
          .Events(e =>
          {
              e.Change("gridChanged");
              e.RequestEnd("wasSaveSuccessful");
          })
      )
        )
    </div>
 
    <script>
 
        function programSelected(e) {
            var grid = $('#MetricGrid');
            var gridSource = grid.data('kendoGrid').dataSource;
 
            gridSource.read();
        }
 
        function additionalData() {
 
            var pt = $('#ProgramTree').data('kendoTreeView'),
            selected = pt.select(),
            item = pt.dataItem(selected);
 
            return {
                id: item.id
            };
        }
 
        function index(dataItem) {
            var data = $("#MetricGrid").data("kendoGrid").dataSource.data();
 
            return data.indexOf(dataItem);
        }
 
        //This is necessary to stop some strange behavior on the ThresholdAssignment
        //column where if the user clicked outside of the radio buttons
        //a default standard string editor would appear.
        function stopEditing(event, element) {
 
            // Don't propogate the event to the document
            if (event.stopPropagation) {
                event.stopPropagation();   // W3C model
            } else {
                event.cancelBubble = true; // IE model
            }
 
        }
 
        function onDataBound() {
 
            var grid = this;
            $("[name*='.ThresholdAssignment']").change(function (e) {
 
 
                var row = $(e.target).closest("tr");
 
                var dataItem = grid.dataItem(row);
                grid.select(row);
                var rowIndex = index(dataItem)
 
                var newValue = 'Metrics[' + rowIndex + '].ThresholdAssignment:checked';
                var radioGroup = $("input:radio[name ='" + 'Metrics[' + rowIndex + '].ThresholdAssignment' + "']:checked").val();
                var radioGroupEnumVal;
 
                //alert(radioGroup);
 
                switch (radioGroup) {
                    case 'Unassigned':
                        radioGroupEnumVal = 0;
                        break;
                    case 'Weekly':
                        radioGroupEnumVal = 1;
                        break;
                    case 'Monthly':
                        radioGroupEnumVal = 2;
                        break;
                    default:
                        radioGroupEnumVal = 0;
                        break;
                }
 
                dataItem.set("ThresholdAssignment", radioGroupEnumVal);
 
            });
        }
 
        function dirtyField(data, fieldName) {
            if (data.dirty && data.dirtyFields[fieldName]) {
                return "<span class='k-dirty'></span>"
            }
            else {
                return "";
            }
        }
 
        function gridChanged(e) {
            if (e.action == "itemchange") {
                e.items[0].dirtyFields = e.items[0].dirtyFields || {};
                e.items[0].dirtyFields[e.field] = true;
            }
        }
 
        function wasSaveSuccessful(e) {
            alert(e.type);
        }
    </script>
Stefan
Telerik team
 answered on 19 May 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
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
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?