Telerik Forums
Kendo UI for jQuery Forum
4 answers
1.1K+ views
Is it possible to make use of the UIHint attribute on a model property such as -
[Display(Name = "Days Late"), UIHint("_DaysToDate"), ReadOnly(true)]
 
public
int? DaysLate

     get; set
}
In order to specify a DisplayTemplate partial as a Template for grid data?

We have a fairly generic grid HTML helper method that uses model attributes whilst binding -
private static GridBuilder<dynamic> CreateDynamicGrid<TBaseViewModelType>(this HtmlHelper helper, string gridName, string provisioningControllerName, string formActionName = "Edit",
bool checkboxRowSelect = false)
{
var type =
typeof(TBaseViewModelType);
var modelProperties =
type.GetProperties().Where(p => p.IsScaffoldable()).ToList();

var
identityProperty = type.GetProperty("Id");

var idFieldName =
string.Empty;

if (identityProperty != null)
{
idFieldName =
identityProperty.Name;
}
 
return
helper.Kendo().Grid<dynamic>()
 .Name(gridName)
.Columns(columns
=> {
columns.Template(t => t).ClientTemplate("<input
class='select-row' type='checkbox' />").HeaderTemplate(t =>
"<input class='select-all-rows' type='checkbox' />").Width(40).Visible(checkboxRowSelect);
columns.Template(t =>
t).ClientTemplate(helper.ActionLink(VisionWebResources.Action_More, formActionName,
provisioningControllerName, new { id = string.Format("#= {0} #", idFieldName) },
null).ToHtmlString()).Visible(identityProperty != null).Width("4em");
modelProperties.ForEach(p =>
columns.Bound(p.GetPrevailingType(), p.Name).Format(p.GetFormatString()).HtmlAttributes(p.GetHtmlAttributes()).Width(InitialColumnWidth));
})
 .DataSource(ds => ds.Ajax()
.PageSize(15) 
.Read(r => r.Action("Read", provisioningControllerName))
 
.Model(model =>
{
model.Id(
"Id");
foreach (var property in
modelProperties) {model.Field(property.Name, property.GetPrevailingType));
 }
 })
)
.Editable(ed =>
ed.Enabled(false))
.Events(events => events.DataBound(
"function() { "
+
 
"if (typeof (gridDataBound) === 'function') { gridDataBound(); }"  +
"}").Change("function() { " +
"
if (typeof (gridFocusedRowChanged) ===
'function') { gridFocusedRowChanged(); }" +
 "
}"))
.Filterable()
.HtmlAttributes(new { @class = "grid" })
.Navigatable()
.Pageable(pages
=>
{
    pages.PageSizes(
new[] { 15, 25, 40 });
    pages.Refresh(
true);
//Provides a button to refresh the current grid page
 })
.Resizable(resize => resize.Columns(true))
.Scrollable(scrollable =>
scrollable.Height(425))
.Selectable(selectable =>
selectable.Mode(GridSelectionMode.Single))
.Sortable(sortable =>
sortable.AllowUnsort(false));
 }

The grid has a dynamic model which is based partially on a fixed ViewModel and partially on dynamic fields which are created and managed by the users within the database (and thus cannot be known in advance). As such the binding is programmatic and not directly to a model. The dynamic fields do not require a display template, I simply wanted to provide some context around our approach.

The line that builds up the columns from the fixed ViewModel is-

modelProperties.ForEach(p => columns.Bound(p.GetPrevailingType(), p.Name).Format(p.GetFormatString()).HtmlAttributes(p.GetHtmlAttributes()).Width(InitialColumnWidth));

Can I add the "ClientTemplate" method to load a partial based on the UIHint value for the property, perhaps use @Html.DisplayFor(), or must this be explicit text?
Daniel
Telerik team
 answered on 31 Oct 2013
1 answer
97 views
Hi,

Stock chart Navigator component's labels/readings are overlapping with each other as highlighted in the attached screen shot. Please help us in resolving this issue.

 
Iliana Dyankova
Telerik team
 answered on 31 Oct 2013
1 answer
11.2K+ views
I would like my grid to be able to scroll horizontally when either the users browser is too small OR when they add additional columns using the Columns menu...

I have tried putting overflow-x:scroll on the surrounding div, but that solution has two problems.
1.) The footer (paging etc..) scroll with the data columns which looks crappy and is not wanted.
2.) The part of the grid that is not visible upon load is not styled, meaning that is has no alternating row colors on it when you start scrolling to the right.

Is there a Kendo supported Vertical scrolling property that I am missing?

Thanks
Jason
Dimo
Telerik team
 answered on 31 Oct 2013
1 answer
270 views
I was asked to hide the first or last row in the month view when all the entries on that row are actually for the next or previous month.  For example for the month of October 2013, the bottom row contains all days in November.

There is no out of the box way to do this but it's actually pretty easy.  I'd like to share my solution and get feedback, please let me know is there is a better way to do it.
//define the cells and rows
var gridCells = $("td[role='gridcell']");                            
var gridRows = $("tr[role='row']"); 
 
//figure out if we should hide the first and/or last row                       
//class will be null if it's normal, otherwise 'k-other-month'                       
if (gridCells[6].getAttribute("class") != null) { $(gridRows[0]).css("display", "none"); }                       
if (gridCells[35].getAttribute("class") != null) { $(gridRows[5]).css("display", "none"); }
I call the above code in my 'dataBound' event handler because I refresh the datasource during navigation.  The 'navigate' handler is probably more appropriate in most cases.

My only concern is that there are other possible classes for the gridcells which I am not yet aware of, which would cause the row to be unintentionally hidden.  Maybe it would be better to check if the class is not 'k-other-month' instead of just looking to see if it is not null?



Vladimir Iliev
Telerik team
 answered on 31 Oct 2013
3 answers
312 views
Hi Kendo UI Team,

I have a grid with dummy data and a client template. I'm attempting to add new records.
<div id="grid">
</div>
<script id="detail-template" type="text/kendo-ui-template">
    <div>
        <p>#: FirstName # #: LastName #'s age is #: Age #</p>
  </div>
</script>
<script type="text/javascript">
    $(document).ready(function(){
        $("#grid").kendoGrid({
            sortable: true,
            editable: "incell",
            toolbar: ["create"],
            columns:[
                {
                    field: "FirstName",
                    title: "First Name"
                },
                {
                    field: "LastName",
                    title: "Last Name"
                }],
            dataSource: {
                schema: {
                    model: {
                        id: "Id",
                        fields: {
                            FirstName: {
                                type: "string"
                            },
                            LastName: {
                                type: "string"
                            },
                            Age: {
                                //data type of the field {Number|String|Boolean} default is String
                                type: "number",
                                // used when new model is created
                                defaultValue: 1
                            }
                        }
                    }
                },
                data: [
                    {
                        Id: 1,
                        FirstName: "Joe",
                        LastName: "Smith",
                        Age: 30
                    },
                    {
                        Id: 2,
                        FirstName: "Jane",
                        LastName: "Smith",
                        Age: 20
                    }]
            },
            detailTemplate: kendo.template($("#detail-template").html()),
            dataBound: function ()
            {
                this.expandRow(this.tbody.find("tr.k-master-row").first());
            },
        });
    });
</script>
Right now I can only edit the fields defined as grid columns, but not the field in the detail template. How can I fix this?
Alexander Popov
Telerik team
 answered on 31 Oct 2013
1 answer
213 views
If I use the theme called Metro Black and have a resource that sets the background color for the event, the text color is either black or white depending on the background color.  It is not somthing that I set, but seems to be handled in the css.  If I change the theme to Flat, the text color is always white, even if the background color of the event is white and is therefore not readable. 

Is there something I can do to make the Flat theme behave the same way as the Metro Black theme with regards to the event text color?

Thanks,
Dimo
Telerik team
 answered on 31 Oct 2013
1 answer
244 views
Hi:

I'm trying to update the majortick during runtime
I have the following:

<script type='text/javascript'>


$("#doctors").change(function () {

var scheduler = $("#scheduler").data("kendoScheduler");

 scheduler.majorTick(60); //interval of 60 minutes
 
kendo.bind($("#scheduler"), scheduler);
$("#scheduler").data("kendoScheduler").refresh();

});

</script>

Somehow, the code is not updating the intervals as a show in the code.

I appreciate in advance

John
Vladimir Iliev
Telerik team
 answered on 31 Oct 2013
1 answer
59 views
Hi Support,
We want to convert our application to HTML5. I see Kendo UI is the best solution for it, but i found that Kendo UI is only available for ASP.NET MVC base. We don't follow MVC pattern in our current application. I just want to make sure, is Kendo UI available for standard ASP.NET pages, If yes please send me that link and also online demo link, i will explore it in detail.

Thanks
Abu Sufyan
Kiril Nikolov
Telerik team
 answered on 31 Oct 2013
1 answer
327 views
As I have posted here I have a problem with setting dataItem.set() manually.

I have an editable Kendo Grid that may have a column with a checkbox to change a boolean value. I have used this solution proposed by OnaBai that is working perfectly!

The only problem is that the checkbox value change is too slow. When user clicks it, it takes about 1 second to change. I realize that the dataItem.set() method is responsible by this delay.

My grid has a considerable amount of data. About 30-40 columns and 300+ lines. It is defined as follows:

$("#mainGrid").kendoGrid({
    dataSource: dataSource,
 
    pageable: false,
    sortable: true,
 
    scrollable: true,
    editable: true,
    autoBind: false,
    columnMenu: true, // Cria o menu de exibição de colunas
    height: getGridHeight(),
 
    toolbar: [/* hide for brevity */],
    columns: [/* hide for brevity */],
    dataBound: function() { /* hide for brevity. */},
    edit: function() { /* hide for brevity. */}
});
Another detail is that, when dataItem.set() is called, it calls dataBound() event but that is not causing the delay. Grid's edit() method is not being called on this process. I don't know if worths to post dataSource code.

Any help will be very appreciate. Thank you in adv.
Kiril Nikolov
Telerik team
 answered on 31 Oct 2013
1 answer
45 views
Let's say I have maxDateGroups set to 10. If I have data going from January 20 to November 15, this data covers less than 10 months, however my chart will display 11 bars, one for each month from January through November. Same behavior with weeks, and probably all the other baseUnits.
T. Tsonev
Telerik team
 answered on 31 Oct 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?