Telerik Forums
UI for ASP.NET MVC Forum
2 answers
149 views
i keep see in code examples, a template  like this
columns.Template(t => { }).HeaderTemplate("").ClientTemplate(@"
< a href='javascript: void(0)' class='abutton edit' onclick='editRow(this)' title='button edit'>button edit</a>
< a href='javascript: void(0)' class='abutton delete' onclick='deleteRow(this)' title='button delete'>button delete</a>")

if i have to give other parameters to that editRow javascript function or multiple,for example a string something like editRow(this,2,'text',g) can i do it ? and how do i format this in that template context?
from the above example some parameters are given by value,some by reference.


and if i write "this" ,always it is interpreted as the sender of that event?it's very insteresting,i write something as a text and it is interpreted as a valid value,in this case a reference.


Regards,
Daniel
Daniel
Top achievements
Rank 1
 answered on 10 May 2013
2 answers
196 views
Hi I have a column in my grid that is a DateTime field with long format date e.g. Friday, May 10, 2013

This is how it is defined in the ViewModel

[Required]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:D}")]
[Display(Name = "Visit Date")]
public DateTime VisitDate { get; set; }
The column is displayed correctly with what I want e.g. Friday, May 10, 2013 but when I get the selected row data for that column it is coming back with the following:
[17:39:18.580] VisitDate: Fri May 10 2013 00:00:00 GMT-0400 (Eastern Daylight Time)
Here is the code on the view to get the selected row.

function deleteRow() {
    var grid = $('#scheduleGrid').data('kendoGrid');
    var rows = grid.select();
    if (rows.length > 0) {
        var dataItem = grid.dataItem(rows);
        console.log("VisitDate: " + dataItem.VisitDate);
    }
}

How do I change it to get the long format date that is displayed in the grid? Any help greatly appreciated.
Vince
Top achievements
Rank 1
 answered on 10 May 2013
1 answer
68 views
I have just returned to using Kendo and put a simple editor on an MVC view. Works fine in Firefox and in IE 10 with compatibility view turned on. With compatibility view turned off the post data for that field is empty.

Is there a specific setting or version that would affect this ?

-Robert
Daniel
Telerik team
 answered on 10 May 2013
1 answer
152 views
Hello dear KendoUI Team!
I've got the following problem:
In one grid, after I insert e new row and click update, the grid does not show the new row. Instead it shows the former first row twice.
After a refresh the new row is shown, so the data is entered correctly on server side.
The grid is ajax bound and inside a tabstrip.
Any Ideas what is going wrong?

brgds
Malcolm Howlett
Daniel
Telerik team
 answered on 10 May 2013
2 answers
380 views
Hi Team
I have a column as shown in the attached excel. I am not finding a way to find the aggregates of the columns 'Fixed' and 'Variable' as mentioned in the excel. Could you please provide with suitable inputs.

-Nikhila
Nikhila
Top achievements
Rank 1
 answered on 10 May 2013
1 answer
486 views
I have a kendo grid with a custom toolbar template that has a button to open a kendo window.

This is the code I use to open my window when the above mentioned button is clicked:
var openAssetEditor = function (e) {
             
            var window = $('#AssetEditorPopUp').data("kendoWindow");
 
            window.wrapper.css({
                height: 450
            });
 
            window.refresh({
                url: "/Asset/AssetPopup",
                data: { assetId: 0 }
            });
 
            window.center();
            window.open();
        };


Right below the grid I have my Window:

@(Html.Kendo().Window()
          .Name("AssetEditorPopUp")
          .Title("Asset Editor")
          .Content("loading asset info...")
          .Draggable(true)
          .Modal(true)
          .Visible(false)
          .Width(950)
      )

My controller for the Popup window:

public ActionResult AssetPopup([DataSourceRequest] DataSourceRequest request, int? assetId)
        {
            return PartialView("~/Views/Asset/AssetPopup.cshtml");
        }

I can't seem to validate the form. I always get back that the form is valid even if all the fields are left blank.

Daniel
Telerik team
 answered on 09 May 2013
2 answers
763 views
I am trying to use CDN for my project however when I use the CDN links instead of my kendo files, nothing displays correctly. I also use a custom Kendo css file which I list after at the end.
<link href="http://cdn.kendostatic.com/2013.1.319/styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2013.1.319/styles/kendo.dataviz.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2013.1.319/styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
 
 
<script src="<%= Url.Content("~/Scripts/jquery.cookie.js") %>"></script>
<link href="<%= Url.Content("~/Content/CustomKendo.css") %>" rel="stylesheet" type="text/css" />
My grids are not returning data or displaying correctly.  My drop down list looks like a text box, and my charts are not showing at all.  Example of how my grid looks attached. Please help!

Jillian
Top achievements
Rank 1
 answered on 09 May 2013
5 answers
1.0K+ views
I am having problems with InLine add and update. If I enter a item that fails the server side validation then the item is still shown as entered/updated. I have followed your examples and looked for threads on this issue, but only found things on PopUp which don't seem to apply here:

The code for add in MVC4 is given below (note: it fails on the ModelState.IsValid, which is correct
[Authorize]
[AcceptVerbs(HttpVerbs.Post)]
[ValidateAntiForgeryToken]
public ActionResult AjaxServiceCreate([DataSourceRequest] DataSourceRequest request, ISmServiceDto newItem, ICreateSmService service)
{
    if (newItem != null && ModelState.IsValid)
    {
        var response = service.Create(newItem);
        if (!response.IsValid)
            response.CopyErrorsToModelState(ModelState);
    }
 
    return Json(new[] { newItem }.ToDataSourceResult(request, ModelState));
}
My razor view is:
@model bool
 
@{
    ViewBag.Title = "Services";
}
 
<h2>Services</h2>
 
@*<div id="message" class="Message"></div>*@
@Html.AntiForgeryToken()
 
@(Html.Kendo().Grid<ServiceLayer.Models.DTOs.SmServiceDto>()
      .Name("Services")
      .Columns(columns =>
                   {
                       columns.Bound(p => p.SmServiceId).Hidden();
                       columns.Bound(p => p.ShortName);
                       columns.Bound(p => p.FullName);
                       columns.Bound(p => p.Locked);
                       if (@Model)
                       {
                           columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
                       }
                   })
      .ToolBar(toolbar =>
                   {
                       if (@Model)
                       {
                           toolbar.Create();
                       }
                   })
      .Editable(editable => editable.Mode(GridEditMode.InLine))
      .Pageable()
      .Sortable()
      //.Scrollable()
      //.HtmlAttributes(new {style = "height:430px;"})
      .DataSource(dataSource => dataSource
                                    .Ajax()                                 
                                    .PageSize(10)
                                    .Events(events => events.Error("error_handler"))
                                    .Model(model =>
                                               {
                                                   model.Id(p => p.SmServiceId);
                                                   model.Field(x => x.SmServiceId).Editable(false);
                                                   model.Field(x => x.Locked).Editable(false);
                                               })
                                    .Create(x => x.Action("AjaxServiceCreate", "Model").Type( HttpVerbs.Post).Data("sendAntiForgery"))
                                    .Read(read => read.Action("AjaxServiceRead", "Model"))
                                    .Update(x => x.Action("AjaxServiceUpdate", "Model").Type( HttpVerbs.Post).Data("sendAntiForgery"))
                                    .Destroy(x => x.Action("AjaxServiceDelete", "Model").Type( HttpVerbs.Post).Data("sendAntiForgery"))
      ))
       
@section scripts {
<script type="text/javascript">
    function error_handler(e) {
        if (e.errors) {
            e.preventDefault();   // cancel grid rebind if error occurs  
            var message = "Errors:\n";
            $.each(e.errors, function (key, value) {
                if ('errors' in value) {
                    $.each(value.errors, function () {
                        message += this + "\n";
                    });
                }
            });
            alert(message);
        }
    
 
    function sendAntiForgery() {
        return { "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val() };
    }
 
</script>
}
Your help on this matter would be appreciated.
Jon Smith
Top achievements
Rank 1
 answered on 09 May 2013
0 answers
135 views
I have a kendo combobox created using
an MVC wrapper like so:

@Html.Kendo.ComboBox().Name("Well");

I want to update the data manually
using a json array stored in javascript (not from an ajax query) - I came
across this code which almost works except that I get [object Object] 3 times
in the ComboBox instead of the 'text' value from the json array:

$("#Well").data("kendoComboBox").dataSource.data([{text:
"i1", value: "1"},
{text: "i2", value: "2"},
{text: "i3", value: "3"}]);

$("#Well").data("kendoComboBox").dataSource.query();


<Edit>

Never mind, found the issue. Sorry about that.

</Edit>

Thanks for your help.

Guga
Top achievements
Rank 1
 asked on 08 May 2013
15 answers
656 views
Hello ,
i have another question regarding columns in the grid.
When i have a client template something like this
......
@(Html.Kendo().Grid<MyProject.ViewModels.TestViewModel>()
.Name("Grid")

.Columns(columns =>
{
.columns.Template(x => { }).ClientTemplate("<a href='#'><img src="" alt=""></img></a>").Width(100)
......
}
but is huge on several lines, for example
@"<a class='k-button' href='javascript: void(0)' onclick='doLoading(this)' style='min-width:32px!important'><span class='k-icon k-edit'></span></a>
<a class='k-button' href='javascript: void(0)' onclick='deleteRow(this);return false;' style='min-width:32px!important'><span class='k-icon k-delete'></span></a>"

can i use a javascript function that return all this html string ?

Regards,
Daniel
Daniel
Top achievements
Rank 1
 answered on 07 May 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
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
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?