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

I am creating a Kendo grid with a datetime column. I want to group the date column so that it is descending. The latest date is on top and the earliest on the bottom. I have come across this line of code

groups => groups.AddDescending(true)

 

But it says that there is no definition for AddDescending. How do I change the grouping? Here is how my grid is defined.

@(Html.Kendo().Grid<LogModel>()
            .Name("Log")
            .Columns(columns =>
            {
                columns.Bound(m => m.dateTimeChangeDate)
                    .Title("Date and Time")
                    .ClientTemplate("#= ChangeDate#")
                    .ClientGroupHeaderTemplate("#= formatUtcDateToLocal(value,  'MM/DD/YYYY')#")
                    .Width("12%");
                columns.Bound(m => m.Component)
                    .Title("Component")
                    .Width("8%")
                    .Filterable(filterable => filterable
                        .UI("componentFilter")
                        .Extra(false)
                        .Operators(operators => operators
                            .ForString(str => str.Clear()
                            .Contains("Contains")
                         ))
                );
                columns.Bound(m => m.Action)
                    .Title("Action")
                    .Width("15%")
                    .Filterable(filterable => filterable
                        .UI("actionFilter")
                        .Extra(false)
                        .Operators(operators => operators
                            .ForString(str => str.Clear()
                            .Contains("Contains")
                        ))
                     );
                columns.Bound(m => m.Changer)
                    .Title("Changer")
                    .Width("10%");
                columns.Bound(m => m.Identifier)
                    .Title("On")
                    .Width("15%");
                columns.Bound(m => m.OldValue)
                    .Title("Old Value")
                    .Width("20%");
                columns.Bound(m => m.NewValue)
                    .Title("New Value")
                    .Width("20%");
            })
            .Filterable()
            .Selectable()
            .Sortable()
            .Groupable()
            .Resizable(resize => resize.Columns(true))
            .ToolBar(toolbar =>
            {
            toolbar.Template(
                @<text>
                    <a class="k-button k-button-icontext k-grid-excel" href="#"><span class="k-icon k-i-excel"></span>Export to Excel</a>
                    <span style='padding-left:35%;font-weight:bold;padding-top:7px'>@ViewBag.ProjectNumber</span>
                    <span style='float:right;font-weight:bold;padding-top:7px'>Total: <span id="change-log-record-count">@ViewBag.ChangeLogRecordAmount</span> records</span>
 
                </text>
                );
            })
            .Excel(excel => excel.AllPages(true).FileName(@ViewBag.ChangeLogType + " Change Log " + @ViewBag.ProjectNumber + ".xlsx").Filterable(true))
            .DataSource(dataSource => dataSource
                 .Ajax()
                 .Model(model =>
                 {
                     model.Id(p => p.Id);
                 })
                 .Read(read => read.Action("FetchChangeLogData", "ChangeLog")
                 .Data("buildParam"))
           )
           .Events(e => e.FilterMenuInit("resizeFilter")
                         .ExcelExport("modifyFormatForExcel")
                         .DataBound("preselectCustomFilter"))
           .ClientDetailTemplateId("change-log-details-template")
    )
Stefan
Telerik team
 answered on 25 Oct 2017
3 answers
487 views

How can we select the node that is clicked on by a right click event?  I am trying to pass the selected node's id on a context menu select event but unless the user left clicks on the node to select it first, the last selected node information gets sent, if one was even selected.

This may be fairly basic, but I can't find any examples of this.

Thanks.

Neli
Telerik team
 answered on 25 Oct 2017
3 answers
525 views

Hi Telerik,

 

I want to know how to add a TreeView inside DropDownList with MVC like your demo in ASP.NET AJAX http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/treeviewcombobox/defaultcs.aspx?product=treeview

 

Can you please help me to resolve this issue?
Thanks

Ivan Danchev
Telerik team
 answered on 24 Oct 2017
1 answer
628 views

I have a tabstrip that loads its content from partial views, and this works well provided the routeValues never change. For example:

@(Html.Kendo().TabStrip()
    .Name("MyTabStrip")
    .Items(i =>
    {
        i.Add().Text("First Tab").LoadContentFrom("FirstAction", "MyController", new { id = ViewData["id"]  });
        i.Add().Text("Second Tab").LoadContentFrom("SecondAction", "MyController", new { id = ViewData["id"] });
    })
)

This will hit FirstAction and SecondAction when the tabs are selected, and carry the id along from ViewData, this is fine.

...but if "id" is a more dynamic bit of data, that needs to change on the page, this approach is no longer valid.  

The TabStrips do not have any Data function, akin to what can be found in the Read attribute in a regular DataSource, which would have been nice, and there is nothing too helpful in the Select event of the TabStrip. I have tried editing the _contentUrls list inside the TabStrip element, but this does not seem to work, either; it seems this is populated when the element is created, but not actually used.

...so how can this be done? Is there any way to update the content urls of an existing tab?

Ivan Danchev
Telerik team
 answered on 24 Oct 2017
8 answers
498 views
Hi, 

Can Grid Hierarchy handle Batch Edit?
Kindly provide sample codes if there is..

Thanks..
Konstantin Dikov
Telerik team
 answered on 23 Oct 2017
1 answer
1.3K+ views

I need to add a horizontal scrollbar at the top of the kendo grid. I've attached a screenshot of what I'd like to be able to do.

 

Thanks

Stefan
Telerik team
 answered on 23 Oct 2017
3 answers
405 views

I have this autocomplete in my application.

@(Html.Kendo().AutoComplete()

  .Name("Name")

  .Placeholder("Please select something...")

  .Delay(300)

  .MinLength(2)

  .DataTextField("Field")        

  .DataSource(source => source

    .Read(read => read

      .Action("SomeAction", "SomeController")

      .Data("SomeData"))

    .ServerFiltering(true))

  .Events(x => x

    .Select("onSelect")           

    .DataBound("onDataBound ")

    .Change("onChange "))

)

It retrieves elements from a table that match a certain condition. On select, in the backend, I change that condition and add the selected element to a grid, which means that that element will not show up in the autocomplete from now on.

@(Html.Kendo().Grid<ViewModel>()
.Name(
"Name")
.Deferred()
.ClientRowTemplate(Html.Partial(
"RowTemplate").ToHtmlString())
.TableHtmlAttributes(
new { @class = "table table-stripped" })
.Events(e => e.Change(
"onChange").DataBound("onDataBound"))
.Resizable(res => res.Columns(
true))
.Columns(columns =>

  {

    columns.Bound(e => e.Code);

     columns.Bound(e => e.Title);

  })

.Filterable()

.Sortable()

.Selectable()

.Pageable(x =>

  {

    x.ButtonCount(3);

    x.Enabled(true);

    x.PageSizes(new[] { "10", "20", "30" });

    x.Refresh(true);

  })

.DataSource(dataSource => dataSource

  .Ajax()

  .Read(read => read.Action("SomeAction", " SomeController "))

  .ServerOperation(true)
))


When I select it in the grid, it restores the condition, which means that element can show up in the autocomplete results again.

This works fine. The problem is that once I change the condition for an element, if I do the same search again, the read action won’t be called, so I won’t get modified elements from the table.

For example, if I do a search on “Doc”, I will get Doc1, Doc2 and Doc3, and if I select Doc1, it will show up in the grid. Now it should not be available as a result in the autocomplete since it no longer matches the initial condition.

If I search “Doc” again, I will get the same result. Doc1 is still there, but if I search “Doc1”, since there was actually a read, it won’t be in the results, which is expected.

So, how can I force an actual read every time I do a search to prevent this situation?

 

Veselin Tsvetanov
Telerik team
 answered on 23 Oct 2017
5 answers
857 views
I have setup a grid to display a complex object like so:

public class A
{
    public DateTime Created { get; set; }
}

public class B
{
    public A Subobject { get; set; }
    public DateTime Created { get; set; }
}

When I pass a list of B objects, the Created fields for both A and B are set properly.  However, while the Kendo grid appears to handle B's Created property as a Date/Time, A's Created property appears to get converted to a string as it appears in the format "/Date(#############)/" when displayed in the grid.

This appears to cause A's Created field to be posted back as a Date/Time.Min value (01/01/0001) when the record is Updated, instead of the "real" value when it was received from the server during the Read operation.  This causes ModelState.IsValid to be false.

Is there any way to fix this?  I found a post related to this at http://www.kendoui.com/forums/ui/grid/date-column-type-doesn-t-work-when-data-source-is-a-datatable.aspx, but can't seem to find where to set a ModelFieldDescriptor in MVC.

EDIT:

Some additional information.  This only happens when the Delete AJAX method is called.  When the Edit AJAX method is called, the Subobject property of object B is null and ModelState.IsValid is true.
Stefan
Telerik team
 answered on 23 Oct 2017
1 answer
380 views

I have a field that can be a fairly long string. I wanted it to show as a textarea instead of as an input. How can this be accomplished?

I've found AJAX implementations but the same structures aren't working in the MVC context. 

Georgi
Telerik team
 answered on 20 Oct 2017
2 answers
588 views

I'm using the recommended approach to using Kendo Widgets in a grid Column ClientTemplate from here: https://docs.telerik.com/aspnet-mvc/helpers/grid/faq#how-do-i-use-a-kendo-ui-widget-inside-a-grid-client-column-template

PROBLEM: The DropDownList I am attempting to use only appears for the first row - all other rows simply show a textbox.  In addition, when I attempt to select an item in the DropDownList, I get a select menu, and a textbox above it with the value "0."

 

VIEW:

@(Html.Kendo().Grid(Model.ProjectViewModels)
    .Name("projectsGrid")
    .ToolBar(tools => tools.Create().Text("Add Project"))
    .Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))
    .Columns(columns =>
    {
        columns.Bound(p => p.Id).Hidden();
        columns.Bound(a => a.ProjectCategoryTypeId)
            .Title("High Level Category")
            .ClientTemplate(
                Html.Kendo().DropDownList()
                    .Name("ProjectCategoryTypeId")
                    .DataValueField("Value")
                    .DataTextField("Text")
                    .BindTo(Model.ProjectCategoryTypes)
                    .HtmlAttributes(new { @class = "templateCell" })
                    .ToClientTemplate()
                    .ToHtmlString())
            .Sortable(true);
 
 
 
        columns.Command(command => command.Destroy()).Width(100);
    })
    .Events(ev => ev.DataBound("initTemplates"))
    .DataSource(dataSource => dataSource
        .Ajax()
        //.Events(e => e.Change("initTemplates"))
        .Model(model =>
        {
            model.Id(p => p.Id);
            model.Field(p => p.Id).Editable(false);
        })
        .ServerOperation(false)
    )
)

 

SCRIPT:

// this approach works, but only for the first row...
function initTemplates(e) {
    $(".templateCell").each(function () {
        eval($(this).children("script").last().html());
    });
}
Stefan
Telerik team
 answered on 20 Oct 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
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Security
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
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?