Telerik Forums
UI for ASP.NET MVC Forum
2 answers
615 views

We are using SignalR binding within our grids to display column information. One thing we would like to do is show custom markup such as a web video. How would we go about displaying a video or custom markup within a Kendo Grid Column? Specifically in the code columns.Bound(p => p.Message) below?

I'm thinking I may need to use a client template, but so far I haven't been able to get it to work.

@(Html.Kendo().Grid<DSTDBContext.Models.Core.Notification>()
 .Name("NotificationHomeGrid")
.HtmlAttributes(new { style = "height: 99%;" })
.Scrollable(o => o.Height("height: 100%;"))      
.Resizable(resizable => resizable.Columns(true))
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.Sortable(sort => sort.SortMode(GridSortMode.MultipleColumn))
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable(pageable => pageable
.Refresh(true)
.Enabled(false)
.PageSizes(false))
.Columns(columns =>
{
columns.Bound(p => p.Id)
.Title("Actions")
.Width(65)
.Filterable(false)
.Sortable(false)
.ClientTemplate("<i class=\"fa fa-exclamation-circle fa-lg\"></i>");
columns.Bound(p => p.NotificationDate)
.Title("Date")
.Width(250)
.Filterable(false)
.Sortable(false)
.ClientTemplate("");

columns.Bound(p => p.Message)
.Title("Notification")
.Width(300)
.Sortable(true)
.Filterable(false);
})

.DataSource(dataSource => dataSource
.SignalR()
.AutoSync(true)
.Events(events => events.Push("onPush"))
.Sort(s => s.Add("CreatedAt").Descending())
.Transport(tr => tr
.Promise("notifyHubStart")
.Hub("notifyHub")
.Client(c => c
.Read("Read")
.Update("Update")
.Create("Create"))
.Server(s => s
.Read("Read")
.Update("Update")
.Create("Create")))
.Schema(schema => schema
.Model(model =>
{
model.Id(p => p.Id);
model.Field("NotificationDate", typeof (DateTime));
model.Field(p => p.Message);
}
)
)
)
)

Milena
Telerik team
 answered on 20 Apr 2016
1 answer
164 views

Sample from RegistrationModel

1.public int Status      {get; set;}
2.public string Batteries    {get; set;}   
3.public List<Batteries> BatteriesList     {get; set;}

    

 

Sample from Grid

1..Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("EditRegistration"))

 

Sample from popup editor template

01.<h2>Batteries</h2>
02.@{
03.   if(Model.BatteriesList != null)
04.   {
05.    <ul>
06.        @foreach(var x in Model.BatteriesList)
07.        {
08.        <li>x.Selection</li>
09.        }
10.    </ul>
11.   }
12.}

 

  • Model.BatteriesList is always null when the popup renders on-screen.
  • I know the BatteriesList is filled with data.
  • The other fields in my Editor Template show data.
  • Not sure what I am missing here.

Can you assist?

 

 

 

 

 

 

 

 

 

           

Dimiter Madjarov
Telerik team
 answered on 20 Apr 2016
2 answers
352 views

Hello,

I want to use Datasources' schema parse but i cant find any where how it use.

Ivan Danchev
Telerik team
 answered on 20 Apr 2016
1 answer
264 views
I'm using Kendo grid in a MVC project. The first column is a checkbox which defines by ClientTemplate:

    .Columns(columns =>
        {
            columns.Bound(c => c.Checked).ClientTemplate(@"<input type='checkbox' class='checkbox' />").Width(50).Title("");
            columns.Bound(c => c.Id).Hidden();
            columns.Bound(c => c.FirstName);
            columns.Bound(c => c.LastName);
            columns.Bound(c => c.Company);  
        })
        
What I want to have is: before click the header, it looks like the 1st screen shot. then make changes to the checkbox, click the header again, it will sort the row by the checkbox status, see screen shot 2.

I tried to set the 1st column sortable, but all others not sortable. Still not works. I think it is because when the data binds to the grid, c.Checked is always false. Now, if we click the checkbox, it does not change the value of that. That's why the sort does not work for this column.

How to make this work?


Thanks

Konstantin Dikov
Telerik team
 answered on 19 Apr 2016
2 answers
973 views

I am getting the error:  JavaScript runtime error: Unable to get property 'xxx' of undefined or null reference.

This occurs when I click the "Add New Record" in my Kendo grid.

Does this have something to do with the way the model in setup?

I was able to add a record previously when my data record was more flattened out.

Please advise.

 

My grid is setup as:

@(Html.Kendo().Grid<MyTest.Models.PersonModel>()
    .Name("myGrid")
    .Columns(col =>
    {
        col.Bound(x => x.Person.ID);
        col.Bound(x => x.Person.Field1);
        col.Bound(x => x.Person.Field2);
        col.Bound(x => x.Person.Field3);
        col.Command(x => {
            x.Custom("Extra Options").Click("showExtraOptions");
            x.Destroy();
        });
    })
    .ToolBar(x =>
    {
        x.Create();
        x.Save();
    })
    .Sortable()
    .Editable(x => x.Mode(GridEditMode.InCell))
    .Navigatable()
    .Scrollable(x => x.Height("auto"))
    .Filterable(x => x
        .Extra(false)
        .Mode(GridFilterMode.Menu)
        .Operators(op => op
            .ForString(str => str.Clear()
                .Contains("Contains")
                .StartsWith("Starts with")
                .IsEqualTo("Is equal to")
            )
        )
    )
    .Pageable(p => p
                .Refresh(true)
                .PageSizes(true)
                .ButtonCount(5))
    .DataSource(ds => ds
        .Ajax()
        .ServerOperation(false) // Paging, sorting, filtering and grouping will be done client-side
        .Batch(true)
        .PageSize(20)
        .Model(m =>
            {
                m.Id(x => x.Person.ID);
            })
        .Read(r => r.Action("GetPerson", "Home"))
        .Create(x => x.Action("CreatePerson", "Home"))
        .Destroy(x => x.Action("DeletePerson", "Home"))
        .Update(x => x.Action("UpdatePerson", "Home"))
    )
)

 

My model is:

public class PersonModel
{
    public My_Person Person{ get; set; }
    public List<Person_Options> PersonOptions { get; set; }
}
 
public class My_Person
{
    public string ID{ get; set; }
    public string Field1 { get; set; }
    public string Field2 { get; set; }
    public string Field3 { get; set; }
}

 

Jim
Top achievements
Rank 1
 answered on 19 Apr 2016
1 answer
259 views

I want export information from a Grid mvc to PDF without the tool bar but with the Client FooterTemplate, because, I  have the total amount about all rows  here

this is mi full code

 

<link href="~/Content/kendo/2016.1.112/kendo.common-material.min.css" rel="stylesheet" />
<link href="~/Content/kendo/2016.1.112/kendo.material.min.css" rel="stylesheet" />
<script src="//cdnjs.cloudflare.com/ajax/libs/jszip/2.4.0/jszip.min.js"></script>
<script src="~/Scripts/kendo/2016.1.112/jquery.min.js"></script>
<script src="~/Scripts/kendo/2016.1.112/kendo.all.min.js"></script>
<script src="~/Scripts/kendo/2016.1.112/kendo.aspnetmvc.min.js"></script>

<style>
    #grid .k-grid-content {
        height: 283px !important;
    }

    #grid > div.k-grid-footer > div > table > tbody > tr > td:nth-child(6) {
        text-align: right;
    }

    #grid > div.k-grid-footer > div > table > tbody > tr > td:nth-child(7) {
        text-align: right;
    }

    /*
        Use the DejaVu Sans font for display and embedding in the PDF file.
        The standard PDF fonts have no support for Unicode characters.
    */
    .k-grid {
        font-family: "DejaVu Sans", "Arial", sans-serif;
    }

    /* Hide the Grid header during export */ 
    /*.k-pdf-export .k-grid-toolbar,
    .k-pdf-export .k-pager-wrap*/
    .k-pdf-export .k-grid-toolbar
    {
        display: none;
    }
    
</style>
@{
    Layout = null;
}

<div id="transactions">
    @(Html.Kendo().Grid<Account.ViewModels.AccountManagement.AccountingViewModel>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.CompanyName);
        columns.Bound(p => p.ContractDescription);
        columns.Bound(p => p.ConceptType);
        columns.Bound(p => p.MovementDate).Title("Date").Format("{0:MMMM dd yyyy}");
        columns.Bound(p => p.Billing).Title("Invoice Number");
        columns.Bound(p => p.PaidFlag).Title("Status").ClientFooterTemplate("Total");
        columns.Bound(p => p.Paid).Title("Amount").Format("{0:c}").HtmlAttributes(new { style = "text-align:right" })
        .ClientFooterTemplate("#= kendo.format('{0:c}', sum) #");
    })
    .ToolBar(tools =>
    {
        tools.Excel();
        tools.Pdf();
    })
    .Excel(excel => excel.FileName("Transaction.xlsx").Filterable(true).ProxyURL(Url.Action("ExcelExportTransactions", "Accounting")))
    .Pdf(pdf=>pdf.AllPages()
    .FileName("Transactions.pdf")
    .Margin(0,1,100,1)
    .ProxyURL(Url.Action("PdfExportTransactions", "Accounting")))
    .Sortable()
    .Scrollable()
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Sort(sort => sort.Add("CompanyName").Ascending())
        .ServerOperation(true)
        .Model(model => model.Id(p => p.MovementID))
                .Read(read => read.Action("ReadTransactions", "Accounting"))
        .Aggregates(a => { a.Add(p => p.Paid).Sum(); })


     )
    )
</div>

Radoslav
Telerik team
 answered on 19 Apr 2016
1 answer
145 views

 

Hi,

 

Is there any telerik control for live tile for MVC ? There is one for ASP.Net but I was hoping to get one for MVC. If not, any ideas on what Telerik control I can use and try getting same behavior ?

Rumen
Telerik team
 answered on 19 Apr 2016
2 answers
507 views
What's the difference between kendo.common-bootstrap.core.min.css and kendo.common-bootstrap.min.css?  

Documentation shows to get Bootstrap 3 to work with Kendo you need to include kendo.common-bootstrap.min.css and kendo.bootstrap.min.css as described via http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/using-kendo-with-twitter-bootstrap

Thanks,
Antony
Top achievements
Rank 1
Iron
 answered on 19 Apr 2016
5 answers
210 views

My application makes use of Adobe TypeKit for loading custom fonts. I'd like the kendo editor to make use of these fonts so staff that are loading content can see what it will look like. Adobe TypeKit loads fonts/css using javascript (see below for example). Is there anyway for me to load this javascript into the iframe? Or is there anyway for me to get the iframe to be able to use the fonts/css loaded by TypeKit?

<script src="https://use.typekit.net/ID_HERE.js"></script>
<script>try { Typekit.load({ async: true }); } catch (e) { }</script>

 

Thanks!

Kyle Smith
Top achievements
Rank 1
 answered on 18 Apr 2016
5 answers
278 views

Hi !

I want to preselect my MultiSelect with values of my ViewModelRole.Functionalities

@(Html.Kendo().Grid<GCM.ViewModel.ViewModelRole>()
      .Name("GridRoles")
      .Columns(columns =>
      {
          columns.Bound(c => c.Designation);
          columns.Command(command => { command.Edit(); command.Destroy(); }).Width(180);
      })
      .ToolBar(toolbar => {
          toolbar.Create();
      })
      .Editable(editable => editable.Mode(GridEditMode.InLine))
      .ClientDetailTemplateId("functionalityPanel")
      .DataSource(dataSource => dataSource
          .Ajax()
          .Model(model => model.Id(p => p.Id))
          .Read(read => read.Action("Roles_Read", "Role"))
          .Create(create => create.Action("Roles_Create", "Role"))
          .Update(update => update.Action("Roles_Update", "Role"))
          .Destroy(destroy => destroy.Action("Roles_Destroy", "Role"))
      )
)
 
<script type="text/javascript">
    function Save(e)
    {
        var roleId = e.event.target.dataset.roleId;
 
        /*
            AJAX Call to update Role.Functionalities
        */
    }
</script>
 
<script id="functionalityPanel" type="text/x-kendo-template">   
    @(Html.Kendo().MultiSelect()
                  .Name("Fonctionnalities_#=Id#")
                  .Placeholder("Choisissez les fonctionnalitées")
                  .AutoClose(false)
                  .DataValueField("Id")
                  .DataTextField("Code")
                  .Value(new List<int> { 1, 2 })
                  .BindTo(ViewBag.functionalities)
                  .ToClientTemplate()
    )
    <br/>
    @(Html.Kendo().Button()
        .Name("Save_#=Id#")
        .Content("Save")
        .HtmlAttributes(new { data_role_id="#=Id#" })
        .ToClientTemplate())
</script>

and my controller

public class RoleController : Controller
    {
        private SolutecNetContext db = new SolutecNetContext();
 
        public ActionResult Index()
        {
            ViewBag.functionalities = db.Functionalities.ToList();
            return View();
        }
 
        public ActionResult Roles_Read([DataSourceRequest]DataSourceRequest request)
        {
            IQueryable<Role> roles = db.Roles;
            DataSourceResult result = roles.ToDataSourceResult(request, role => new ViewModelRole{
                Id = role.Id,
                Designation = role.Designation,
                FunctionalitiesIds = GetFunctionalitiesIds(role.Functionalities)
            });
 
            return Json(result);
        }
 
        private List<int> GetFunctionalitiesIds(ICollection<Functionality> functionalities)
        {
            List<int> functionalitiesIds = new List<int>();
 
            foreach(Functionality f in functionalities)
            {
                functionalitiesIds.Add(f.Id);
            }
 
            return functionalitiesIds;
        }
 
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Roles_Create([DataSourceRequest]DataSourceRequest request, ViewModelRole viewModelRole)
        {
            if (ModelState.IsValid)
            {
                var entity = new Role
                {
                    Designation = viewModelRole.Designation
                };
 
                db.Roles.Add(entity);
                db.SaveChanges();
                viewModelRole.Id = entity.Id;
            }
 
            return Json(new[] { viewModelRole }.ToDataSourceResult(request, ModelState));
        }
 
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Roles_Update([DataSourceRequest]DataSourceRequest request, ViewModelRole viewModelRole)
        {
            if (ModelState.IsValid)
            {
                var entity = new Role
                {
                    Id = viewModelRole.Id,
                    Designation = viewModelRole.Designation
                };
 
                db.Roles.Attach(entity);
                db.Entry(entity).State = EntityState.Modified;
                db.SaveChanges();
            }
 
            return Json(new[] { viewModelRole }.ToDataSourceResult(request, ModelState));
        }
 
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Roles_Destroy([DataSourceRequest]DataSourceRequest request, ViewModelRole viewModelRole)
        {
            if (ModelState.IsValid)
            {
                var entity = new Role
                {
                    Id = viewModelRole.Id,
                    Designation = viewModelRole.Designation
                };
 
                db.Roles.Attach(entity);
                db.Roles.Remove(entity);
                db.SaveChanges();
            }
 
            return Json(new[] { viewModelRole }.ToDataSourceResult(request, ModelState));
        }
 
        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }

 

and I want to do something like

.Value("#=Functionalities#")

Is it possible ? Did I miss something ?

 

Thank for your help !

Adrien
Top achievements
Rank 1
 answered on 18 Apr 2016
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
+? 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?