Telerik Forums
UI for ASP.NET MVC Forum
1 answer
167 views
Hello Guys,


I have the following dropdownlist with a custom template:

        Html.Kendo()
           .DropDownList()
           .HtmlAttributes(new { style = "width:100%; " })
           .BindTo(Model.FilterShops)
           .DataTextField("DisplayValue")
           .DataValueField("Id")
           .Template("<input type='checkbox' id='#=data.Id #' name='superPlayer#=data.Id #' value='#=data.IsSelected #' />" + "   " + "${ data.DisplayValue}")
           .Name("cb_SuperPlayer")
           .Events(ev => ev.Close("cb_SuperPlayer_closed"))
           .Filter(FilterType.Contains)

If i open the dropdownlist and check some of the checkboxes, on the close event i will correctly get the ones checked into an array. 
The problem is when i use the search textbox of the control to filter the items, if i check some of them, after the dropdownlist closes the selections are all cleared..

So for example lets say that my collection has: [Whatever, Test1, Test2, SomeOtherText]. If i just open the dropdownlist and select whatever and test1 and then close it, after i collapse it again, my checkboxes are still checked.

If i open the dropdownlist and search for "test", and check test1, test2, close the dropdownlist and then collapse it again, the two selections are cleared.

Hope you can help me figure this out.

P.S: This is the method for onclosed to get the checked selections

      function cb_SuperPlayer_closed() {
        var selShops = new Array();
        var doc = document.getElementById("cb_SuperPlayer_listbox");
        var chkBoxes = doc.getElementsByTagName("input");
        for (var i = 0; i < chkBoxes.length; i++) {
            if (chkBoxes[i].checked)
                selShops.push(chkBoxes[i].id);
        }

    }

Regards,


Fran









Alexander Popov
Telerik team
 answered on 02 Mar 2015
1 answer
130 views
Hi,

I'm reading from a dataset from a SQL database to my chart, I've managed all chart types except for one as the data coming back is dynamic. Essentially I am need to have the startDate that is already returned to be my x axis and then I want to stack by database column the monthly information. The problem is I don't know what the columns are called after the startDate and don't know how many there are. 

I've been looking now for over 24 hours at various solutions and have so far come up blank. My charts are written using the MVC approach but I've also been trying the JavaScript approach. All seems OK until I try to load the series information in. The data is going to be coming at me in the following format:

Public class websiteInformation
{
    public string DisplayDate { get; set; }
    public List<WebSiteInfo> WebSite { get; set; }
}
 
Public class WebSiteInfo
{
    public decimal Value { get; set; }
    public string WebSiteName { get; set; }
}

The razor looks like this:

@(Html.Kendo().Chart<websiteInformation>()
      .Theme("BlueOpal")
      .Name("WebSiteInfo")
      .ChartArea(chartArea => chartArea.Background("transparent"))
      .SeriesDefaults(sd => sd.Column().Stack(true))
      .DataSource(ds => ds
          .Read(read => read.Action("WebSiteInfo", "Home", new
          {
              param1 = "param1value",
              param2 = "param2value",
              param3 = "param3value",
              param4 = "param4value",
              param5 = "param5value"
          }))
          .Events(e => e.RequestStart("chart4LoadingStart").RequestEnd("chart4LoadingEnd"))
      )
      .Series(series =>
      {
        ?????????????????????????
      })
      .Legend(l => l.Position(ChartLegendPosition.Bottom))
      .Tooltip(tt => tt.Visible(true).Template("#= kendo.format('{0:P}', percentage) #").Color("white"))
)

What I need to know is how to dynamically configure the series so I can have the x axis as the DisplayDate then the Y stacked for each month all the WebSiteInfo so the Value and the WebSiteName will be used in the tooltip.

Hope this all makes sense,and hopefully someone can help?
Thanks in advance.
T. Tsonev
Telerik team
 answered on 02 Mar 2015
1 answer
85 views
Hi,

In the following code snippet you see that we are using the MVC Wrapper of kendo ui grid with odata mechanism that gets its data from a controller in server side.
We want to use custom command buttons but we are getting an exception that says that we cannot use custom commands if we are not using server binding. But when we are using odata mechanism with data binding at controller stage, why this is not a server binding ?

Please help.

Thanks.

<div>
    @(Html.Kendo().Grid<Item>()
          .Name("grid")
          .Columns(columns =>
          {
              columns.Bound(c => c.ItemCode);
              columns.Bound(c => c.ItemName);
              columns.Command(command => command.Custom("Details").Text("Details").Action("OpenDetailsForm", "Home")).Width(100);
          })
          .HtmlAttributes(new { style = "height: 380px;" })
          .Scrollable()
          .Selectable(o => o.Mode(GridSelectionMode.Multiple).Type(GridSelectionType.Row))
          .Sortable()
          .Resizable(o => o.Columns(true))
          .Reorderable(o => o.Columns(true))
          .Filterable()
          .Pageable(pageable => pageable
          .Refresh(true)
          .PageSizes(true)
          .ButtonCount(3))
          .DataSource(dataSource => dataSource
          .Custom()
          .ServerSorting(true)
          .ServerFiltering(true)
          .ServerPaging(true)
          .ServerGrouping(true)
          .ServerAggregates(true)
          .Schema(s => s.Total("Total").Data("Data"))
          .Type("odata")
          .PageSize(10)
          .Transport(r => r.Read(c => c.Cache(true)).Read(a => a.Action("GetGridDataSource", "Home", new { entityName = typeof(Item).FullName }).DataType("json")))))
</div>







Alexander Popov
Telerik team
 answered on 02 Mar 2015
9 answers
382 views
I've just finished implementing the Export to Excel functionality from v2014.3.1411 in apps for two different clients. I held off until now because the first version of the functionality, while great, was unusable to me because if the grid had more than one page of data, the export only exported the current page. The latest version with AllPages functionality fully implemented is perfect. It completely meets my clients' needs for ad hoc reporting. Thank you so much and my compliments to the developers involved.
Jolene
Top achievements
Rank 1
 answered on 27 Feb 2015
5 answers
1.5K+ views
Hello,
How can I force the grid to refresh after saving an edit using your pop-up editor? 

After a user saves a new or edited record, its data is encrypted and passed to the database.  When we return to the grid, the new records data is displayed in its encrypted form, but the other records display properly.  After I hit the refresh button on the grid, everything displays properly.  This is the issue that I am trying to correct.

I would appreciate your help and suggestions,
Mike
Kelso
Top achievements
Rank 1
 answered on 27 Feb 2015
1 answer
151 views
In Razor view i have Three divs out of which Two divs are hidden,in hidden div i have declare one div for Grid and i am generating that Grid using html,When i am showing that hidden div then Grid in that div is coming at the left top corner with small size.
When i am clicking on it, it's showing that Grid properly.
I am Showing and Hiding these div using "js" file.

(When i am removing hidden property from that div and loading that div it's not giving me any Problem)i.e
Working Fine Without Hidden:
<div id="xyz" >
<div id="Grid_ID"/>
</div>

Issue  With Hidden Property:
<div id="xyz" hidden="hidden">
<div id="Grid_ID"/>
</div>

I have attached the Snap shot,Kindly Find those.
Dimo
Telerik team
 answered on 27 Feb 2015
1 answer
115 views
I have created a grid which is bound to a list of workgroups. Each workgroup has a list of Agents which I want to show as detail.

The only way I got this working was by doing a  client detail template and creating a new grid. This means doing another read of data which i did not really want to do. 

Can someone advise a better way to do this. Also suggest a good way to style my details as I don't want them shown as a standard grid but actually a list. 
  
Current code:

   <div id="clientsDb">
    <%: Html.Kendo().Grid<ASML_Scheduler.ScheduleService.WorkgroupViewData>()
        .Name("grid")
         .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("Workgroups_Read", "Home", new { name = ViewData["LoggedInUser"] }))
            )
        .Columns(columns =>
        {
            columns.Bound(c => c.WorkgroupName).Width(140);
            columns.Bound(c => c.TotalAgents).Width(75);
            columns.Bound(c => c.AgentsLoggedOn).Width(75);

        })       
        .HtmlAttributes(new { style = "height: 380px;" })
        .Scrollable()
        .Groupable()
        .Sortable()        
        .ClientDetailTemplateId("client-template")
        .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(true)
            .ButtonCount(5))     
     %>
 </div>

<script id=" Code:client-template" type="text/x-kendo-template">     
  <%: Html.Kendo().Grid<ASML_Scheduler.ScheduleService.AgentViewData>()
      .Name("grid_#=WorkgroupName#") 
        .DataSource(dataSource =>  
          dataSource.Ajax().Read(read => read.Action("Agents_Read", "Home", new {workgroupname= "#=WorkgroupName#", name = ViewData["LoggedInUser"] }))
      )      
      .Columns(columns =>
      {
          columns.Bound(product => product.AgentName);
          columns.Bound(product => product.IsLoggedOn);
      })       
      .ToClientTemplate()
    %>    
</script>
Alexander Popov
Telerik team
 answered on 27 Feb 2015
1 answer
305 views
Hi There,

I would like to do dynamic columns using list item from MyModel, can i change the column "title" base on MyModel?

MyModel
{
     List<Item> Items;
}


Please refer to code below : 

@(Html.Kendo().Grid<MyModel>()
    .Name("gridStudentList")
    .Columns(columns =>
    {


        for (int i = 0; i < 3; i++)
        {

            columns.Bound(c => c.Items[i].Product).Title("Can i use Mymodel property here?").Filterable(false); 
            columns.Bound(c => c.Items[i].ProductPrice).Filterable(false); 
        }

    })
Thanks for your time. Regards,






Dimo
Telerik team
 answered on 27 Feb 2015
4 answers
276 views
Hello,

I'm using the GridFilterMode.Row but it doesn't work. My Grid is define in two parts :
- on the server :
    public static class GridPluginServeurTypeA
    {
        public static GridBuilder<T> Grid<T>(HtmlHelper htmlHelper) where T : class
        {
            WidgetFactory wf = new WidgetFactory(htmlHelper);
            GridBuilder<T> gb = wf.Grid<T>();
            gb.Name("Grid");
            gb.Pageable(pager => pager.PageSizes(new[] { 5, 10, 20, 50, 75, 100 }).ButtonCount(3).Refresh(true));

            gb.Sortable(s => s.SortMode(GridSortMode.MultipleColumn));
            gb.Navigatable();
            gb.Pageable();
            gb.Groupable();
            gb.Resizable(resiz => resiz.Columns(true));
            gb.Reorderable(reoder => reoder.Columns(true));
            gb.DataSource(dataSource => dataSource.Ajax()
                .PageSize(10)
                .Batch(false)
                .ServerOperation(true)
            );
            gb.Events(e => e.DataBound("onDataBound"));

            return gb;
        }
    }

- on the client :
 Gtool.Utilities.Telerik.Grid.GridPluginServeurTypeA.Grid<Keorisk.Domain.DtoTUtilisateur>(Html)
            .Columns(columns =>
            {
                columns.Bound(p => p.Id).Title(TexteAffiche.Instance.Texte["LstUtilisateurColId"]).ClientTemplate("#= ColonneId(data) #").Locked(true);
                columns.Bound(p => p.Nom).Title(TexteAffiche.Instance.Texte["LstUtilisateurColNom"]).Locked(true).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
                columns.Bound(p => p.Prenom).Title(TexteAffiche.Instance.Texte["LstUtilisateurColPrenom"]).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
                columns.ForeignKey(p => p.RoleId, (System.Collections.IEnumerable)ViewData["roles"], "Id", "Libelle").Title(TexteAffiche.Instance.Texte["LstUtilisateurColRole"]).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
                columns.ForeignKey(p => p.StatutId, (System.Collections.IEnumerable)ViewData["statuts"], "Id", "Libelle").Title(TexteAffiche.Instance.Texte["LstUtilisateurColStatut"]).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
                columns.Bound(p => p.Login).Title(TexteAffiche.Instance.Texte["LstUtilisateurColLogin"]);
                columns.Command(com => { com.Edit().Text("Edit"); com.Destroy().Text("Cancel "); });
            })
            .Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("Utilisateur"))
            .Filterable(ftb => ftb.Mode(GridFilterMode.Row).Enabled(true))
            .DataSource(dataSource => dataSource.Ajax()
                .Model(model => model.Id(user => user.Id))
                .Model(model => model.Field(user => user.Id).Editable(false))
                .Model(model => model.Field(user => user.RoleId).Editable(false))
                .Model(model => model.Field(user => user.StatutId).Editable(false))
                .Read(read => read.Action("GetAllUtilisateursGrid", "Admin"))
                .Update(update => update.Action("UpdateUtilisateurGrid", "Admin"))
                .Destroy(update => update.Action("DestroyUtilisateurGrid", "Admin"))
            )
)


The filter row is not visible and I don't understand why.

Can anybody help me ?


Alexander Popov
Telerik team
 answered on 27 Feb 2015
7 answers
786 views
I'm trying to get some editor templates in child grids.  They work fine in the parent grid but when I try to add them to the child grid, the .ToClientTemplate() returns invalid Template format.  Not sure what else to do. Thnx


Here's the code :
(Parent grid):
@(Html.Kendo().Grid<PDT.Dashboard.Models.CategoryVM>()
                    .Name("CategoryGrid")
                    .HtmlAttributes(new { @class = "expandable-rows grid-within-grid" })
                    .Editable(editable => { editable.Mode(GridEditMode.InLine); editable.DisplayDeleteConfirmation(false); })
                    .Columns(columns =>
                    {
                        columns.Bound(a => a.CategoryIconId)
                            .Title("Icon")
                            .ClientTemplate("<span class='icon30 gray-icon notes-icon-#= CategoryIconId #'></span>")
                            .EditorTemplateName("EditCategoryIcon")
                        columns.Bound(a => a.CategoryName)
                            .EditorTemplateName("EditCategoryName");
                        columns.Bound(a => a.IsDeleted)
                            .Title("Active")
                            .ClientTemplate("<span> #= IsDeleted ? 'Active' : 'Inactive' #</span>")
                        columns.Bound(a => a.SortOrder)
                            .EditorTemplateName("EditSortOrder")
                        columns.Command(command => { command.Edit().HtmlAttributes(new { title = "Edit" }); }).Width(55);
                    })
                    .Sortable()
                    .Pageable(p => p.PageSizes(new[] { 10, 20, 50, 100 }))
                    .ClientDetailTemplateId("AdminSubCategoryTemplate")
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .PageSize(20)
                        .Read(read => read.Action("GetCategories", "Permissions"))
                        .Create(create => create.Action("AddCategory", "Permissions"))
                        .Update(update => update.Action("UpdateCategory", "Permissions"))
                        .Model(model => { model.Id(m => m.CategoryId);  })
                                    .Sort(s => { s.Add(m => m.SortOrder).Ascending(); })
                        .Events(e =>
                        {
                            e.Error("categoryErrorHandler");
                        })
                    ))






​ @(Html.Kendo().Grid<PDT.Dashboard.Models.SubCategoryVM>()
        .Name("grid_#=CategoryId#")
        .Editable(editable => { editable.Mode(GridEditMode.InLine); editable.DisplayDeleteConfirmation(false); })
        .ToolBar(tb => tb.Create())
        .Columns(columns =>
        {
            columns.Bound(a => a.SubCategoryName)
                            .EditorTemplateName("EditSubCategoryName");
            columns.Bound(a => a.IsDeleted)
                .Title("Active")
                .ClientTemplate("<span> \\#= IsDeleted ? 'Active' : 'Inactive' \\#</span>")
            columns.Bound(a => a.SortOrder).Width(100);
            columns.Command(command => { command.Edit(); }).Width(70);
        })
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(5)
            .Read(read => read.Action("GetSubCategories", "Permissions", new { categoryId = "#=CategoryId#" }))
            .Create(create => create.Action("AddSubCategory", "Permissions", new { parentCategoryId = "#=CategoryId#" }))
            .Update(update => update.Action("UpdateSubCategory", "Permissions"))
            .Model(model =>
            {
                model.Id(m => m.SubCategoryId);
                model.Field(m => m.CategoryId).Editable(false);
            })
            .Sort(s => { s.Add(m => m.SortOrder).Ascending(); })
            .Events(e =>
            {
                e.Error("subcategoryErrorHandler");
            })
        )
        .Pageable()
        .Sortable()
        .ToClientTemplate()
    )


EditCategoryName.cshtml:

<span class="k-widget k-numerictextbox" >
<span class="k-numeric-wrap k-state-default k-expand-padding">
        <input class="k-input text-box single-line" id="CategoryName" name="CategoryName" type="text" value="" data-bind="value:CategoryName">
    </span>
</span>






EditSubCategoryName.cshtml:
<span class="k-widget k-numerictextbox" >
<span class="k-numeric-wrap k-state-default k-expand-padding">
        <input class="k-input text-box single-line" id="SubCategoryName" name="SubCategoryName" type="text" value="" data-bind="value:SubCategoryName">
    </span>
</span>










Kelso
Top achievements
Rank 1
 answered on 26 Feb 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?