Telerik Forums
UI for ASP.NET MVC Forum
6 answers
307 views
 Hello All,
        I have a client detail template like this,
<script id="ItemsMoreTemplate" type="text/x-kendo-template">
<div class="form-group required">
        <div class="col-sm-2 control-label">
            @Html.LabelFor(x => x.Expire1Message)
        </div>
        <div class="col-sm-3">            
            @Html.Kendo().TextBoxFor(x => x.Expire1Message).HtmlAttributes(new { , required=true ,id = "Expire1Message_#=Id#", @class = "form-control", value = "#if(Expire1Message!=null){##=Expire1Message##}#" })
            
        </div>
    </div>
</script>

I am just expanding this template when I click the edit button (just expanding on edit event from grid) and the data are binding well. 
 I updated the post data source on Save event of kendo grid. Anyway the value is updating and getting saved.
 But my problem is the validation, original grid text boxes are validating well, but my client template text boxes are not validating, because no validation message or required attributes are added to the text box. 

Is there any way to do validate the client detail template text boxes??
Kindly advice me.
 


Chris
Top achievements
Rank 1
 answered on 29 Oct 2020
1 answer
445 views

Greetings Telerik

I have the following Grid which I fill from a DataTable, everything works fine but when I add .Events (events => events .Change ("onChange")) it doesn't load anything, could you please help me, thank you very much in advance.

 

@model System.Data.DataTable

@(Html.Kendo().Grid<dynamic>
          ()
          .Name("rgvListado")
          .HtmlAttributes(new { style = "height: 650px;" })
          .Scrollable()
          .ToolBar(t => t.Search())
          .Columns(columns =>
          {
            foreach (System.Data.DataColumn column in Model.Columns)
            {
              var c = columns.Bound(column.ColumnName);
            }
          })
          .Sortable()
          .Groupable()
          .Selectable(selectable => selectable
            .Mode(GridSelectionMode.Single)
            .Type(GridSelectionType.Row))
          .DataSource(dataSource => dataSource
            .Ajax()
            .Model(model =>
            {
              foreach (System.Data.DataColumn column in Model.Columns)
              {
                var field = model.Field(column.ColumnName, column.DataType);
              }
            })
            .Read(read => read.Action("ReadTable", "General"))
            .ServerOperation(false)
          )
          .Events(events => events
            .Change("onChange"))
          )

Eyup
Telerik team
 answered on 28 Oct 2020
6 answers
1.3K+ views
Hi,
How to expand the detail template automatically when ClientRowTemplate is used? Here is the code I have. Not sure what is missing.
 
@(Html.Kendo().Grid<Models.ResViewModel>()
        .Name("grid")
        .HtmlAttributes(new { style = "height:550px; width:100%;" })
        .ClientRowTemplate(
            "<tr data-uid='#: uid #' class='k-master-row' role='row'><td class='k-hierarchy-cell' aria-expanded='true'><a class='k-icon k-i-collapse' href='\\#' aria-label='Collapse' tabindex='-1'></a></td>" +
                "<td>" +
                      "<div ><span><b>Name :</b></span> #: FullName# </div>" +
                      "<div >Contact Info/Comments : #: Comments# </div>" +
                      "<div >State : #: State# </div>" +
                      "<div >SRID : #: SRID# </div>" +
                "</td>" +
             "</tr>"
        )
 
        .ClientDetailTemplateId("questionTemplate")
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(1)
            .Model(model => model.Id(p => p.SID))
            .Read(read => read.Action("GetResponses", "SUser"))
        )
        .Events(events => events.DataBound("dataBound"))
        .Scrollable()
        .Pageable(pageable => pageable
                    .Refresh(false)
                    .ButtonCount(5))
)
 
<script id="questionTemplate" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<Models.SQViewModel>()
            .Name("grid_#=State#")
            .Columns(columns =>
            {
                columns.Bound(o => o.SortOrder);
                columns.Bound(o => o.QuestionText);
            })
             .Pageable()
            // .AutoBind(true)
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(5)
                .Read(read => read.Action("DetailTemplate_HierarchyBinding_Questions", "SUser", new { surveyID = "#=SID#" }))
            )
            .Events(events => events.DataBound("dataBound"))
            .ToClientTemplate()
    )
</script>
<script>
    function dataBound() {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
        this.expandRow(this.tbody.find("tr.k-detail-row").first());
    }
</script>
KR
Top achievements
Rank 1
Veteran
 answered on 28 Oct 2020
4 answers
1.7K+ views

Greetings, I am wanting to fill a grid, with a json result, I do not use a model since this table is going to be loaded from data that its structure is not known, because it will be a general data window, I am trying to do the following but I can't show the content.

 

@(Html.Kendo().Grid<dynamic>()
          .Name("rgvListado")
          .HtmlAttributes(new {style = "height: 650px;"})
          .Scrollable()
          .ToolBar(t => t.Search())
          .Sortable()
          .Groupable()
          .Selectable(selectable => selectable
            .Mode(GridSelectionMode.Single)
            .Type(GridSelectionType.Row))
          .DataSource(dataSource => dataSource
            .Custom()
            .Type("odata")
            .Transport(transport =>
            {
              transport.Read(read =>
                read.Url("https://demos.telerik.com/kendo-ui/service/products")
                  .DataType("jsonp")
                );
            }))
          )

 

How do I display a content either in the DataSource property or from jquery?
How do I make the columns auto-generate?

 

thank you very much in advance, nice evening

Ivan Danchev
Telerik team
 answered on 28 Oct 2020
1 answer
367 views

I am using asp.net mvc kendo tools. I have a int property from my c# model side, see below:

 

public class MyModel

{

[Required]

public int MyIntField {get;set;

}

 

in the view side I am adding the column using Kendo Grid selector
...

.Columns(c => c.Bound(my=>my.MyIntField))

...

 

That field always shows with zero when an edit popup screen is called. How can I avoid that still keeping the automatic required UI validations and without messy changing the DOM directly using javascript?
I'm looking for a kendo selector solution or a c# attribute side solution. But maybe I am asking for too much.

thanks

Martin
Telerik team
 answered on 27 Oct 2020
1 answer
94 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
158 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: "&nbsp;", 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.3K+ 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.4K+ 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
91 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
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
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?