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


I have a Kendo grid with sorting, filtering and column menu enabled.  Out of the box, there are two clickable actions in each column header:
  *  Clicking the title in the column header sorts the data in that column 
  *  Clicking the chevron column menu icon displays the column menu options
 
What I’d like to accomplish - instead of a sort being applied when the title in the column header is clicked is for the column menu options (sort asc, sort desc, columns, filter) to appear.  Essentially, I want the title in each column header to take the place of the chevron icon.  Is this possible?  The main motivation is that some of the columns are just too narrow (ex: 40px)to properly display all the default icons.  Is there some event that can be intercepted to do this?  BTW, I am using the MVC  Html wrappers to setup the grid - if that matters.

Thanks,
R Cornish
Nikolay Rusev
Telerik team
 answered on 14 Nov 2013
9 answers
768 views
Hi, i am trying to follow this guide and rewrite it to the Razor syntax:
Preserve grid state in cookie example.

The difference from my code and the example code is that they use AutoBind: false.
I cant use that in Razor because i initialize the data into the model when the view is rendered.

Another difference is that the example uses schema: syntax, don't think i need that when using razor, Am i correct?

Here is my razor code:

01.@model IEnumerable<Backend.ViewModel.ViewSalon>
02.<div id="salonDetail">
03. 
04.    @(Html.Kendo().Grid(Model)
05.          .Name("Grid")
06.          .Columns(c =>
07.                   {
08.                       c.Bound(m => m.Id).Width(30);
09.                       c.Bound(m => m.Name).Width(110).HtmlAttributes(new { @class = "customerName" });
10.                       c.Bound(m => m.Telephone).Width(100);
11.                       c.Bound(m => m.ContactPerson).Width(100);
12.                       c.Bound(m => m.City).Width(50);
13.                       c.Bound(m => m.StatusId).HtmlAttributes(new { @class = "statusid" }).Hidden();
14.                       c.Bound(m => m.Kundnr).Width(50);
15. 
16.                   })     
17.                  .Scrollable()
18.                  .DataSource(dataSource => dataSource       
19.                  .Ajax()               
20.                  .ServerOperation(false)  
21.                )
22. 
23.                  .ColumnMenu()
24.                  .Reorderable(reorder => reorder.Columns(true))
25.                  .Resizable(resize => resize.Columns(true))
26.                  .Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
27.                  .Sortable()
28.                  .Filterable()
29.                  .Events(events => events.Change("onChange").DataBound("onDataBound").DataBinding("onDataBinding"))
30.                  .HtmlAttributes(new { style = "height: 408px" })
31.          )
32.</div>
01.@* Loads cookie support *@
03. 
04.<script type="text/javascript">
05.     //START: *** Save grid state ***
06.     
07.    function onDataBound(e) {
08.        var grid = $(this).data("kendoGrid");
09.        var dataSource = this.dataSource;
10. 
11.        var state = kendo.stringify({
12.            page: dataSource.page(),
13.            pageSize: dataSource.pageSize(),
14.            sort: dataSource.sort(),
15.            group: dataSource.group(),
16.            filter: dataSource.filter()
17.        });
18. 
19.        $.cookie("customerState", state);
20. 
21.        if ($.cookie('customerRows')) {
22.            $.each(JSON.parse($.cookie('customerRows')), function () {
23.                var item = dataSource.get(this);
24.                var row = grid.tbody.find('[data-uid=' + item.uid + ']');
25.                row.addClass('k-state-selected');
26.            });
27.        }
28.    }
29.     
30.    function onChange(e) {
31.        var grid = $(this).data("kendoGrid");
32.        var ids = grid.select().map(function () {
33.            return grid.dataItem($(this)).Id;
34.        }).toArray();
35.        $.cookie('customerRows', JSON.stringify(ids));
36.    }
37. 
38.    function parseFilterDates(filter, fields) {
39.        if (filter.filters) {
40.            for (var i = 0; i < filter.filters.length; i++) {
41.                parseFilterDates(filter.filters[i], fields);
42.            }
43.        }
44.        else {
45.            if (fields[filter.field].type == "date") {
46.                filter.value = kendo.parseDate(filter.value);
47.            }
48.        }
49.    }
50.     
51.    function onDataBinding() {
52.       
53.    }
54. 
55.    $(document).ready(function () {
56.        var grid = $('#Grid').data("kendoGrid");
57. 
58.        var state = JSON.parse($.cookie("customerState"));
59.        if (state) {
60.            if (state.filter) {
61.                parseFilterDates(state.filter, grid.dataSource.options.schema.model.fields);
62.            }
63.            grid.dataSource.query(state);
64.        }
65.        else {
66.            grid.dataSource.read();
67.        }
68.         
69.        // END: *** Save grid state ***
70.</script>

 

Dan
Top achievements
Rank 1
 answered on 13 Nov 2013
1 answer
99 views
Hi,

Combo box server side filter working  only in IE10 but not IE9/8. When i open developer tool ( under network => start capturing)
ajax request is not sending for IE 9/8 but ajax request sending in IE10. I saw the HTML source code for both ie9 and ie10 . Its was same.

Please find attached scripts and css files


HTML Code.
(.cshtml)
<link href="@Url.Content("~/Content/kendo/2013.2.918/kendo.dataviz.min.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/kendo/2013.2.918/kendo.metro.min.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/kendo/2013.2.918/kendo.dataviz.metro.min.css")" rel="stylesheet" type="text/css" />

    <script type="text/javascript"  src="@Url.Content("~/Scripts/kendo/2013.2.918/jquery.min.js")"></script>
    <script type="text/javascript"  src="@Url.Content("~/Scripts/kendo/2013.2.918/kendo.all.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/kendo/2013.2.918/kendo.aspnetmvc.min.js")"></script>


<
div>
        @(Html.Kendo().ComboBox()
          .Name("countires")
          .Filter("contains")
           .HtmlAttributes(new { style = "width:250px" })
          .Placeholder("please select")
          .DataTextField("Text")
          .DataValueField("Value")
          .DataSource(source =>
              source.Read(read =>
                      {
                          read.Url("http://localhost:59590/api/Search/GetCountires");
                      }).ServerFiltering(true))
          .HighlightFirst(true)
          .IgnoreCase(true)
          .AutoBind(false)
          .Suggest(true)
    )
    </div>
Server side code

[HttpGet]
 public List<MVC.SelectListItem> GetCountires(string text)
 {
     
     text = string.IsNullOrEmpty(text) ? null : text.ToUpper();
     DataTable results = Counties.GetALLCountires(text);
     return ConvertToSelectListItem(results);
 
 }

Petur Subev
Telerik team
 answered on 13 Nov 2013
4 answers
508 views
Hi

How can i use the x-kendo-template for my grid toolbar?

Before I got something like this:
kendoGrid({
toolbar: kendo.template($("#toolbarTemplate").html())
});

and a corresponding script like:
<script type="text/x-kendo-template" id="toolbarTemplate">
  <div class="toolbar">
  </div>
</script>

how can i use the same template script inside asp.net mvc kendo ui grid
@(Html.Kendo().Grid(Of CProductionDataGridViewModel)().Name("datagrid").ToolBar(Sub(toolbar)
  toolbar.Template("kendo.template($('#toolbarTemplate').html()")
End Sub))

Thanks
Matt Miller
Top achievements
Rank 1
 answered on 12 Nov 2013
3 answers
716 views
Here is a code snip:
@Html.Kendo().MultiSelectFor(model => model.Programs).BindTo((SelectList)ViewBag.Programs).DataTextField("Text").DataValueField("Id").Name("SelectedProgramIds ")
ViewBag.Programs is populated by:
Models.Program[] obj = model.List();
ViewBag.Programs = new SelectList(obj, "Id", "Name", project.Programs);

I'm also using:
public IEnumerable<String> SelectedProgramIds { get; set; }
.. as the property for the saved value in the model.

After I POST, SelectedProgramIds  contains the Text Name (but not values) of the entries in the MultiSelect control.  How can I get the Value as set by 
DataValueField(), instead of the DataTextField() after POST?

Also, when the control loads, how can existing items be selected?  Currently the box is empty.
Petur Subev
Telerik team
 answered on 12 Nov 2013
5 answers
582 views
hey guys.

I'm using a grid with popup editmode which looks like:

@(Html.Kendo().Grid<Pattern>()
.Name("Pattern")
.ToolBar(toolbar =>
        {
 
            toolbar.Create().Text("New Pattern");
        }
 
    )
    .DataSource(dataSource =>
        dataSource.Ajax().PageSize(50)
            .Model(model =>
                    {
                        model.Id(s => s.RegExID);
                        model.Field(s => s.Category).DefaultValue(new Category());
                        model.Field(s => s.Table).DefaultValue(new ExpressionTable());
                        model.Field(s => s.Version).DefaultValue("%");
                    }
                )
            .Create(create => create.Action("CreatePattern", "Pattern"))
            .Destroy(destroy => destroy.Action("DeletePattern", "Pattern"))
            .Update(update => update.Action("UpdatePattern", "Pattern"))
            .Read(reader => reader.Action("LoadPattern", "Pattern"))
        )
    .Sortable()
    .Selectable()
    .Pageable(pager =>
        {
            pager.Enabled(true).Refresh(true).PageSizes(new int[] { 50, 100, 150 });
            pager.Info(false);
 
        })
    .Scrollable(s => s.Enabled(true).Height(500))
    .Filterable(filterable =>
                    filterable.Extra(false).Operators(operators => operators
                        .ForString(str =>
                            str.Clear()
                            .StartsWith("Starts with")
                            .Contains("Contains")
                    )
                    )
 
    )
    .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("PatternPopUp")
 
)
)

The Template used looks like this:
@Html.HiddenFor(model => model.RegExID)
 
<div class="editor-label">
    @Html.LabelFor(model => model.Table)
</div>
<div class="editor-field">
    @(Html.Kendo().DropDownListFor(model => model.Table)
    .OptionLabel("Please select a value")
    .HtmlAttributes(new { style = "width: 200px" })
    .AutoBind(true)
    .Name("Table")
    .DataTextField("Name")
    .DataValueField("TableID")
    .Events(e =>
        {
            e.Select("select");
            e.DataBound("bound");
        }
        )
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetRegExpressions", "Pattern");
        })
        .ServerFiltering(true);
    })
 
    )
</div>
 
<div id="regSW">
    <div class="editor-label">
        @Html.LabelFor(model => model.SoftwareName)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.SoftwareName)
        @Html.ValidationMessageFor(model => model.SoftwareName)
    </div>
    <div class="editor-label">
        @Html.LabelFor(model => model.SoftwarePublisher)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.SoftwarePublisher)
        @Html.ValidationMessageFor(model => model.SoftwarePublisher)
    </div>
    <div class="editor-label">
        @Html.LabelFor(model => model.Version)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Version)
        @Html.ValidationMessageFor(model => model.Version)
    </div>
</div>
 
<div id="regMachine">
    <div class="editor-label">
        @Html.LabelFor(model => model.InstallSource)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.InstallSource)
        @Html.ValidationMessageFor(model => model.InstallSource)
    </div>
</div>
 
<div class="editor-label">
    @Html.LabelFor(model => model.Category)
</div>
<div class="editor-field">
    @(Html.Kendo().DropDownListFor(model => model.Category)
    .OptionLabel("Please select a value")
    .HtmlAttributes(new { style = "width: 200px" })
    .AutoBind(false)
    .Name("Category")
    .DataTextField("Name")
    .DataValueField("CategoryID")
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetCategories", "Software");
        })
    .ServerFiltering(true);
    })
    )
</div>
 
<div class="editor-label" id="regDeslbl">
    @Html.LabelFor(model => model.Description)
</div>
<div class="editor-field" id="regDesfld">
    @Html.TextAreaFor(model => model.Description, new { @class = "k-textbox", style = "width: 200px" })
    @Html.ValidationMessageFor(model => model.Description)
</div>
 
<script>
 
    $("#regSW").hide();
    $("#regMachine").hide();
</script>

what I want to implement now is something like this:
after the sumbit(save, update) button is clicked I don't want the window to close. I want it to remain open and display something like a progressbar or an ajax loader to inform the user that sth. is happening right now and there's no need to submit again.

in the background there will be items added to the database and I want to display the amount of items added on a new view.

when the db operation is finished the loader should disappear and something like: 6 items have been added to the database should be displayed on a lets call it success view.

hopefully there's a way without creating kendo windows, having partial views with the content displayed and an ajax.beginform.

thanks in advance
cheers, tom
Alexander Popov
Telerik team
 answered on 12 Nov 2013
0 answers
234 views
Hi,
Facing an issue while binding tooltip to database item, below is the code for reference - 

<Series>
                    <telerik:ColumnSeries Name="Power" Stacked="true" DataFieldY="TotalPower" AxisName="Power">
                        <Appearance>
                            <FillStyle BackgroundColor="#36b8f4"></FillStyle>
                        </Appearance>
                        <LabelsAppearance Position="Center" Visible="false">
                        </LabelsAppearance>
<TooltipsAppearance ClientTemplate="#= dataItem.TotalPower#">
                        </TooltipsAppearance>

                
<%--
    <TooltipsAppearance ClientTemplate="#= kendo(\'{0:dd MMM yy}\', dataItem.Date)#<br/>Power: #= kendo.format(\'{0:N2}\',dataItem.TotalPower)# kW">
                        </TooltipsAppearance>
--%>
                               <%--
<TooltipsAppearance ClientTemplate="#=dataItem.Date#<br/>Power: #=dataItem.TotalPower# kW">
                        </TooltipsAppearance>--%>
                        
                    </telerik:ColumnSeries>
</Series>

When i use ClientTemplate in TooltipsAppearance to bind tooltip to TotalPower value (this value comes from dataset), it shows "undefined" on mouse over, and instead of ClientTemplate if dataformatstring is used then it display the value
(<TooltipsAppearance DataFormatString="{0}"></TooltipsAppearance>).

My requirement is that, i want to display both Date and TotalPower values in tooltip. Also, tried using kendo after googling this issue, but still without any success.

Please help as I'm stuck into this.
Jitendra
Top achievements
Rank 1
 asked on 12 Nov 2013
6 answers
675 views
How to remove file from Kendo Upload MVC  file-list which is hidden by default? Previously in Telerik Upload I have used the code below but it do not works anymore.

    this.removeFile = function (fileName) {       
        fileName = fileName.split("'")[0];
        $('span.k-filename[title="' + fileName + '"]').parent().remove();
    };
Dimiter Madjarov
Telerik team
 answered on 12 Nov 2013
1 answer
209 views
Hello all! We have a KendoGrid on our MVC view, and it works great - the only question is when a user clicks the Save Changes button, how does the UI know when that action is complete if it is an AJAX request?  In our case the grid is bound to server generated data, with Add and Save buttons in the tool bar.  When a user enters invalid data into the grid as determined by the data annotations on the model, it works and shows the errors. We have no way of knowing if a successful save occurred though from what i've seen. Any ideas?

Thanks in advance!
Rosen
Telerik team
 answered on 12 Nov 2013
2 answers
147 views
Hi,

I am looking to implement the kendo ui tooltip for MVC. With the way I have it implemented now, I am getting a whole bunch of random symbols showing up in my tooltip.

I've attached a screen shot of what I am seeing and attached the relevant portions of code I am using. I am hoping to fill my ServiceTypeToolTip div with significantly more content and there will be about 20 of these such sections on the page. 

*I am using Kendo 2013.1.319

Any help would be appreciated.

Thanks!

    @(Html.Kendo().Tooltip()
        .For("#ServiceTypeImg")                
        .ShowOn(TooltipShowOnEvent.Click)
        .AutoHide(false)
        .Animation(true)
        .ContentTemplateId("ServiceTypeToolTip")
        .Position(TooltipPosition.Right)
        .Width(120)
    )
    
    <div id ="ServiceTypeToolTip">
        <p>this is one line</p>
        <p>this is line 2</p>
        <p>this is a very very very very ver yver yveryv eryvery veyrvey rye long line</p>
    </div>

<img src="~/Images/question-mark-icon-tiny-small.png" id="ServiceTypeImg" />








Tim
Top achievements
Rank 1
 answered on 11 Nov 2013
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
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Wizard
Security
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
SegmentedControl
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?