Telerik Forums
UI for ASP.NET MVC Forum
1 answer
359 views
I'm having problems to add/edit/delete rows on a grid loaded from DataTable

I have something like the following code:
@(Html.Kendo().Grid<object>()
        .HtmlAttributes(new { style = "height: 80%;" })
        .Name("grid-records")
        .Columns(columns =>
        {
            columns.LoadSettings(Model.GridColumns);
            foreach (GridColumnSettings item in Model.GridColumns)
            {
                ModelFieldDescriptor modelField = new ModelFieldDescriptor();
                modelField.Member = item.Member;
                modelField.MemberType = item.MemberType;
                modelField.DefaultValue = null;
                modelField.IsEditable = true;              
                columns.Container.DataSource.Schema.Model.Fields.Add(modelField);
            }
            //columns.Command(command => { command.Edit(); command.Destroy(); }).HtmlAttributes(new { style = "float:right;" });
            columns.Command(command => command.Custom("ViewDetails"));
        })
        .Groupable()
        .Pageable()
        .Sortable()
        .Scrollable()
        .Filterable(Web.Helpers.KendoI18n.SetGridFilterableSettings)
        //.Editable(editable => editable.Mode(GridEditMode.InLine))
        .DataSource(dataSource => dataSource
            .Ajax()
            .Events(events => events.Error("error_handler"))
            .Read(read => read.Action("GetRecords", "Records", new { currentTableId = Model.CurrentTableId }))
            //.Update(update => update.Action("UpdateRecordFromGrid", "Design"))
            //.Destroy(destroy => destroy.Action("DeleteRecordFromGrid", "Design"))
        )
    )
In the above code if I uncomment the "commented lines" .. the exception is:

"Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions." 

Could you tell me what I should do to enable CRUD operations on this case?

Thanks
Petur Subev
Telerik team
 answered on 18 Mar 2013
1 answer
145 views
Is it possible to have only create and destroy button BUT NO EDIT button shown in a grid?

I have tried not to include edit command but on addition, the update and cancel buttons are not shown.

regards
Iliana Dyankova
Telerik team
 answered on 18 Mar 2013
1 answer
232 views
Hi!
I have problem with client-side validation.  Even after I set Culture and it shows proper date format, when I submit page client-side validation fires error "The field Datum očitavanja must be a date.". Here is my code in view:

@model ISPIS.Models.TerenskiRezultatFK
 
@section headCultureContent {
    <script src="@Url.Content("~/Scripts/kendo.culture.sr-Latn-RS.min.js")"></script>
}
  
<script type="text/javascript">
    //set culture of the Kendo UI
    kendo.culture("sr-Latn-RS");
</script>
  
 
@{
    ViewBag.Title = "Create";
    Culture = "sr-Latn-RS";
}
<div class="editor-label">
    @Html.LabelFor(model => model.DatumOcitavanja)
</div>
<div class="editor-field">
 
    @(Html.Kendo().DateTimePicker()
    .Name("DatumOcitavanja")
    .Value(DateTime.Now)
    /*.Culture("sr-Latn-RS")*/
    .Format("dd.MM.yyyy HH:mm")
    .HtmlAttributes(new { style = "width:220px" })
    )
 
    @Html.ValidationMessageFor(model => model.DatumOcitavanja)
</div>
Please for some instruction. Thanks!
Vladimir Iliev
Telerik team
 answered on 18 Mar 2013
2 answers
179 views
@* Html contains html string from model *@

<script id="news-item-template" type="text/x-kendo-template">
    <div class="wrapper">
        <figure class="img-indent indent-top1 img-indent-none-mp">
            <img src="${imgPath}" alt="" />
        </figure>
        <div class="extra-wrap clear-ml">
                ${Html}
        </div>
        <div class="edit-buttons">
            <a class="k-button k-button-icontext k-edit-button" href="\\#"><span class="k-icon k-edit"></span>Edit</a>
            <a class="k-button k-button-icontext k-delete-button" href="\\#"><span class="k-icon k-delete"></span>Delete</a>
        </div>
    </div>
</script>

    <div class="container_12">
        <div class="wrapper">
            <div class="grid_7 left">
                <div class="box">
                <h3>Latest News</h3>

                    <div class="k-toolbar k-grid-toolbar">
                        <a class="k-button k-button-icontext k-add-button" href="#"><span class="k-icon k-add"></span>Add new record</a>
                    </div>

                    @(Html.Kendo().ListView<MyClub.Models.xtbl_NewsItem>(Model)
                        .Name("listView")
                        .TagName("div")
                        .ClientTemplateId("news-item-template")
                        .DataSource(dataSource => dataSource
                            .Model(model => model.Id("Id"))
                            .PageSize(3)
                            .Create(create => create.Action("NewsCreate", "Home"))
                            .Read(read => read.Action("NewsRead", "Home"))
                            .Update(update => update.Action("NewsUpdate", "Home"))
                            .Destroy(destroy => destroy.Action("NewsDestroy", "Home"))
                        )
                        .Pageable()    
                        .Editable()
                    )

                </div>
            </div>
        </div>
    </div>


Dimiter Madjarov
Telerik team
 answered on 18 Mar 2013
2 answers
755 views
Hello,

I need some help to complete below functionality.

I am trying to bind/create a template column, so when the grid loads it can call an html helper or controller action to get the value/text for that column. Which means, i am trying to bind a non modal or datasource property  to one of the grid columns.

Goal: Bind one of the columns in kendo grid with external text.

My grid looks something like this,

 @(Html.Kendo().Grid<Model>()
          .Name("Grid")
          .AutoBind(false)
          .Columns(columns =>
              {
                  columns.Bound(row => row.Id).Hidden(true);
                  columns.Bound(row => row.Name);

                 columns.Template(@<text>@Html.GetSomeText("SomeContext")</text>).Title("title");

                 columns.Template(@<text>@Html.Action("GetSomeText", "controller", new {ctx = SomeContext})</text>);
               }

As you can see above, I tried couple of ways to get the text for the column - Html helper and Action Method, but in both the cases, server side code is not even being triggerd and column remains empty in the grid.

Any help is much appreciated.

Thanks,
Balwant
Petur Subev
Telerik team
 answered on 18 Mar 2013
5 answers
439 views
Hi, 

during evaluation of the KEndo library, I am now facing the next problem which I spent a lot time with now...

I try to create a listview. My viewmodel contains references to other classes, let's say I have a model class Person, which contains a property Address of type Address, which again has properties "Street" and "City".

So, I defined my template like this (also my editor template):
<script type="text/x-kendo-tmpl" id="template">
     <div>
       <dl>
         <dt>Street</dt> <dd>${Address.Street}</dd>
         <dt>City</dt> <dd>${Address.City}</dd>
       </dl>
     </div>
 </script>
But this leads to JavaScript exceptions, saying that the property is undefined. How can I handle this? Any idea is welcome, but this really a serious problem with complex data models. I cannot reduce my viewmodel to only have primitive properties, that woud cause too much effort...

Thanks!
Petur Subev
Telerik team
 answered on 18 Mar 2013
1 answer
709 views
I have an ASP MVC 4, .Net 4.5 project.  I am using the new EmailAddressAttribute validation data annotation attribute on my view models to validate a correct email format is posted.

The attribute is correctly rendered on the input element as <input type="text" ... data-val-email="Email address format is incorrect" .../>.

If I use the kendo validator to validate my form before post to server, the email rule seems to be ignored.  I believe I have included all the necessary js files to support unobstrusive validation.  All my other data annotation rules are applied correctly.

When I look at kendo.aspnetmvc.min.js, it appears as though the kendo "email" rule is never mapped to the data-val-email rule pattern?

If I write my input element from scratch <input type="email" required .../> obviously my email rule is applied correctly by the kendo validator.  This is not an ideal solution though because I am trying to standardise on using the data annotation attributes for my view models.

Can you please tell me if I have done something wrong?  I rechecked the 2012 q3 beta and it appears to have the same limitation.

Thanks





Shiva
Top achievements
Rank 1
 answered on 16 Mar 2013
1 answer
244 views
Maybe I'm going about this the wrong way but the model populating the AutoComplete has an Id and a Name.  I display the Name but when the form is submitted I need to return the Id since it will bind to the property on the model.

Presently the AutoComplete is populated correctly when I start entering data, but when I submit the form, the widget has the red border meaning that it's not returning the int property type but the string type.

These are two of the AutoComplete properties on my model that I need to bind to:
[DisplayName("Vendor")]
public int? VendorId { get; set; }
 
[DisplayName("Category")]
public int CategoryId { get; set; }
Here is my Vendor AutoComplete widget:
@(Html.Kendo().AutoComplete().Name("Expense.VendorId")
    .DataTextField("VendorName")
    .Filter(FilterType.StartsWith)
    .Placeholder("Type in a Vendor...")
    .DataSource(dataSource =>
    {
        dataSource.Read(read => read.Action("_GetVendors", "Expense"));
    })
    )
Bottom line: I need to bind the Id of the selected value back to the controller, so I need to know how to return the Id from the AutoComplete widget and include it with the response.

Any help on this is appreciated.

Thanks.
King Wilder
Top achievements
Rank 2
 answered on 15 Mar 2013
1 answer
124 views
I have a Db table that has a SiteKey, SiteValue, Description columns. No Id's.
For example,
SiteKey    SiteValue
ACode     ABC
BCode     XYZ
CCode    123
I want to display this in a View
--------------------------
A Code: ABC
B Code: XYZ
C Code: 123
---------------------------
| EDIT |
----------------------------
And a Button to Edit. On click, make the display boxes for values to Inline Editing with the option to Save or Cancel.
Can you show me a sample to do this with Kendo? I am able to do this as a separate Edit View but want to use kendo widgets if possible. Since the data is unrelated, not sure what to use or if this is possible.

Annie

Dimiter Madjarov
Telerik team
 answered on 15 Mar 2013
4 answers
151 views
Hi everyone,

I'm a database engineer new to the ASP.NET MVC world, and recently purchased the Telerik Kendo UI tool kit for ASP.NET MVC in order to transition away from Silverlight. While I appreciate the thoroughness of the examples provided by Telerik, what I would have preferred is individual projects for the various tools. I'm sure those accustomed to working with MVC in general are able to cut through all the chaff and get to what they need, but all I really want is to understand how to use a basic grid for now; I'll build on that understanding later. A project/solution with just a basic grid implementation would save me a lot of time.

Does anyone know if there is a project repository on Telerik or KendoUI.com that would suit my needs? I've looked through the forums, but figured I'd start asking here before submitting a support ticket.

Thanks in advance for any help for this novice!
Nate
Top achievements
Rank 1
 answered on 15 Mar 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
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
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
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?