Telerik Forums
UI for ASP.NET MVC Forum
1 answer
790 views

my requirement is to have a custom button on each data row.

When a user clicks the button the detail row expands for that specific row only.

I am able to expand and collapse using the button, but its doing it for the entire grid. 

What do i need to do to keep it to the current(selected) row.

command.Custom("View Classes").Click("showClasses");

function showClasses(e)

{

    var grid = $("#Grid").data("kendoGrid");

      if ("tr.k-state-selected")

           {
               var $link = grid.tbody.find("td.k-hierarchy-cell .k-icon");
                $link.click();
            }

}

Eyup
Telerik team
 answered on 30 Jan 2017
1 answer
156 views

How can I avoid the copy/paste technique shown below in which certain columns of my grid need to have the Is Null, Is Not Null and other built-in filters removed but allow other columns in that same grid to use Is Null, Is Not Null, etc. ?

I do NOT want to do this GLOBALLY for the entire Grid, just certain columns (that are required when they are input into the system, so null and not null are not wanted or needed by the customer).

What I have works, but it seems terribly inefficient to have to physically repeat all that .Filterable() information for each column that needs it. 

.Columns(c =>
        {
            c.Bound(q => q.FirstName)
                .Filterable(filterable => filterable
                    .Extra(false)
                    .Operators(operators => operators
                        .ForString(str => str.Clear()
                            .IsEqualTo("Is equal to")
                            .IsNotEqualTo("Is not equal to")
                            .Contains("Contains")
                            .DoesNotContain("Does not contain")
                            .StartsWith("Starts with")
                            .EndsWith("Ends with")
                        ) // ForString
                    ) // Operators
                ); // Filterable
 
            c.Bound(q => q.LastName)
                .Filterable(filterable => filterable
                    .Extra(false)
                    .Operators(operators => operators
                        .ForString(str => str.Clear()
                            .IsEqualTo("Is equal to")
                            .IsNotEqualTo("Is not equal to")
                            .Contains("Contains")
                            .DoesNotContain("Does not contain")
                            .StartsWith("Starts with")
                            .EndsWith("Ends with")
                        ) // ForString
                    ) // Operators
                ); // Filterable
 
            c.Bound(q => q.Email)
                .Filterable(filterable => filterable
                    .Extra(false)
                    .Operators(operators => operators
                        .ForString(str => str.Clear()
                            .IsEqualTo("Is equal to")
                            .IsNotEqualTo("Is not equal to")
                            .Contains("Contains")
                            .DoesNotContain("Does not contain")
                            .StartsWith("Starts with")
                            .EndsWith("Ends with")
                        ) // ForString
                    ) // Operators
                ); // Filterable
Niko
Telerik team
 answered on 30 Jan 2017
1 answer
411 views

Hi,

I have a Grid MVC with some DropDownList columns. I can select any item from dropdownlists, but when I add new record to grid, the selected items from DropDownList columns are cleared.
How can I mantain the selected data adding new records to grid?


Regards

 

01.@(Html.Kendo().Grid(Model.Subsidiaries)
02.            .Name("Subsidiaries")
03.            .ToolBar(tools => tools.Create().Text("Agregar nuevo"))
04.            .Editable(editable => editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))
05.            .Scrollable()
06.            .Columns(columns =>
07.            {
08.                columns.Bound(c => c.SubsidiariesName).ClientTemplate("#=SubsidiariesName #" +
09.                    "<input type='hidden' name='Subsidiaries[#= indexSubsidiariesCommercial(data)#].SubsidiariesName' value='#= SubsidiariesName #' />"
10.                );
11.                columns.Bound(c => c.Address).ClientTemplate("#=Address #" +
12.                    "<input type='hidden' name='Subsidiaries[#= indexSubsidiariesCommercial(data)#].Address' value='#= Address #' />"
13.                );
14.                columns.Bound(c => c.PhoneNumber).ClientTemplate("#=PhoneNumber #" +
15.                    "<input type='hidden' name='Subsidiaries[#= indexSubsidiariesCommercial(data)#].PhoneNumber' value='#= PhoneNumber #' />"
16.                );
17.                columns.Bound(p => p.BusinessUnitsId).ClientTemplate(
18.                    @Html.DropDownList("Subsidiaries[#= indexSubsidiariesCommercial(data)#].BusinessUnitsId", ViewBag.BusinessUnits as SelectList, "Seleccione",
19.                    htmlAttributes: new { @class = "form-control" }).ToHtmlString()
20.                );
21.                columns.Bound(p => p.Id).ClientTemplate(
22.                    @Html.DropDownList("Subsidiaries[#= indexSubsidiariesCommercial(data)#].Countries", ViewBag.Countries as SelectList, "Seleccione",
23.                    htmlAttributes: new { @class = "form-control", @onchange = "changeCountry(this.value, #= indexSubsidiariesCommercial(data)#)" }).ToHtmlString()
24.                );
25.                columns.Bound(p => p.Id).ClientTemplate(
26.                    @Html.DropDownList("Subsidiaries[#= indexSubsidiariesCommercial(data)#].Departments", ViewBag.Departments as SelectList, "Seleccione",
27.                        htmlAttributes: new { @class = "form-control", @disabled = "disabled", @onchange = "changeDepartment(this.value, #= indexSubsidiariesCommercial(data)#)"
28.                    }).ToHtmlString()
29.                );
30.                columns.Bound(p => p.CitiesId).ClientTemplate(
31.                    @Html.DropDownList("Subsidiaries[#= indexSubsidiariesCommercial(data)#].CitiesId", ViewBag.Cities as SelectList, "Seleccione",
32.                    htmlAttributes: new { @class = "form-control", @disabled = "disabled" }).ToHtmlString()
33.                );
34.                columns.Bound(c => c.SourceCreated).ClientTemplate("#=SourceCreated #" +
35.                    "<input type='hidden' name='Subsidiaries[#= indexSubsidiariesCommercial(data)#].SourceCreated' value='#= SourceCreated #' />"
36.                ).Hidden(true);
37.                columns.Bound(c => c.UserCreated).ClientTemplate("#=UserCreated #" +
38.                    "<input type='hidden' name='Subsidiaries[#= indexSubsidiariesCommercial(data)#].UserCreated' value='#= UserCreated #' />"
39.                ).Hidden(true);
40.                columns.Command(command => command.Destroy()).Width(100);
41.            })
42.            .DataSource(dataSource => dataSource
43.                .Ajax()
44.                .ServerOperation(false)
45.                .Model(model =>
46.                {
47.                    model.Id(s => s.Id);
48.                    model.Field(p => p.UserCreated).DefaultValue(HttpContext.Current.GetOwinContext().
49.                        Authentication.User.Claims.First(x => x.Type == System.IdentityModel.Claims.ClaimTypes.GivenName).Value);
50.                    model.Field(p => p.SourceCreated).DefaultValue(HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString()
51.                        + "/" + HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString());
52.                })
53.            )
54.)
Konstantin Dikov
Telerik team
 answered on 30 Jan 2017
10 answers
412 views

Hi,

We have implemented a scheduler for managing activities with some filters. It works fine but we are confronted to some problems.

 

So, for ressources we have a list of products, and each events is associated to an event.The first problem is that the list is little big. So when we apply the filters we need to filter events and ressources. Actually for doing this we catch event filterings and we get ids by applying filter to the events for refreshing ressources. But when we refresh ressources, that refresh events read. It works but it's very slow when we swithch days and weeks.

var selected = new Array();
        var selectedSites = new Array();
        var scheduler = $("#mainScheduler").data("kendoScheduler");
        var dataSource = scheduler.dataSource;
        var filters = dataSource.filter();
        var allData = dataSource.data();
        var query = new kendo.data.Query(allData);
        var filteredData = query.filter(filters).data;
        $.each(filteredData, function(index, item) {
            if ($.inArray("" + item.RendezVousID + "", selected) === -1) {
                selected.push("" + item.RendezVousID + "");
            }
            if ($.inArray("" + item.SiteID + "", selectedSites) === -1) {
                selectedSites.push("" + item.SiteID + "");
            }
        });


        $.ajax({
            url: '@Url.Action("GetProduitsSitesFilter", "Schedule")',
            data: { activiteId: @Model.ActiviteID, products: selected.join(","), sites: selectedSites.join(",") },
            type: 'POST',
            async: false,
            success: function(data) {
                var dataSch = [];
                for (var i = 0; i < data.length; i++) {
                    var content = data[i].Text;
                    dataSch.push({ Text: content, ProdLibelleCourtEndode: content, Value: data[i].Value });
                }
                subDataSource.data(dataSch);
                $("#isFilter").val("1");

            }
        });

 

We are just looking an easy way for filtering events and ressources just matching with events.

Philippe
Top achievements
Rank 1
 answered on 30 Jan 2017
1 answer
95 views

I would like to let user choose some option by checkbox.

ClientTemplate let me put checkbox in cell, but I do not know how to keep checkbox text as cell value.

Could anybody help me plz? thx

@(Html.Kendo().Window().Name("HandleNotPermitted")
.Title("化性不合格處置")
.Visible(false)
.Modal(true)
.Resizable()
.Draggable(true)
.Width(700)
.Content(@<text>
@( Html.Kendo().Grid<Template.Areas.TestResult.Models.LIMS_Chemical_TestResult>()
        .Name("NotPermittedGrid")
        .Columns(columns =>
        {
            columns.Bound(p => p.TestId).Width(120);
            columns.ForeignKey(p => p.TestNo, (System.Collections.IEnumerable)ViewData["TestDesc"], "TestNo", "TestDesc").Width(80);
            columns.ForeignKey(p => p.TagNo, (System.Collections.IEnumerable)ViewData["TagDesc"], "TagNo", "TagDesc").Width(150);
            columns.ForeignKey(p => p.Plant, (System.Collections.IEnumerable)ViewData["Plant"], "ItemValue", "ItemName").Width(60);
            columns.Bound(p => p.TestEqp).Width(100);
            columns.Bound(p => p.Notification).Width(110).ClientTemplate(
                "<div class='form-group'>" +
                    "<div class='checkbox'>" +
                        "<label>" +
                            "<input type = 'checkbox' id = 'notes'>" +
                            "Notes通知" +
                        "</label>" +
                    "</div>" +
                    "<div class='checkbox'>" +
                        "<label>" +
                            "<input type = 'checkbox'>" +
                            "簡訊通知" +
                        "</label>" +
                    "</div>" +
                    "<div class='checkbox'>" +
                        "<label>" +
                            "<input type = 'checkbox'>" +
                            "重新檢驗" +
                        "</label>" +
                    "</div>" +
                    "<div class='checkbox'>" +
                        "<label>" +
                            "<input type = 'checkbox'>" +
                            "開立異常單" +
                        "</label>" +
                    "</div>" +
                "</div>"
                    );
        }
        )
        .ToolBar(toolbar =>
        {
            toolbar.Template("<a class='k-button k-button-icontext k-grid-save-changes' onclick='SaveResult1()'><i class='fa fa-check-circle-o''></i>   確認</a>");
            //toolbar.Excel().Text("匯出Excel");
        }
        )
        .Editable(editable => editable.Mode(GridEditMode.InCell))
        .Excel(excel => excel.AllPages(true))
        .Events(events => events.Edit("edit"))
        .DataSource(dataSource => dataSource
            .Ajax()
            .Sort(sort => sort.Add("StartTime").Descending())
            .ServerOperation(false)
            .PageSize(10)
            .Batch(true)
            .Events(events => events.Error("error_handler"))
            .Model(model =>
            {
                model.Id(p => p.TestId);
            })
            .Update(Update => Update.Action("ChemicalTestResult_Update", "ChemicalTestResult"))
        //.Read(read => read.Data("filterDetails3").Action("Instrument_EditingPopup_Read_Details3", "Instrument_Manage"))
        )
)
Eyup
Telerik team
 answered on 30 Jan 2017
5 answers
833 views

I've successfully used the Telerik MVVM with stand HTML form field elements, but how do I bind a viewModel property to a Telerik MVC Textbox?  I'm assuming through the .HTMLAttributes method, but I don't know the syntax to use... Where would I put the data-bind?

@(Html.Kendo().TextBox()
    .Name("docketNumber")
    .HtmlAttributes(new { placeholder = "Docket Number", required = "required", validationmessage = "Enter {0}" })
}
Joe
Top achievements
Rank 1
 answered on 29 Jan 2017
1 answer
234 views

Initially I was using the CDN for including all the Kendo JS and CSS files...  However, we decided within the company we wanted to use the local files instead.  However, when we publish our web application, it takes a very, very, very long time because of all the nested JS and CSS folders and files.  What can I safely remove from my Scripts and Content webfolders to make the webapp publishing process faster? 

I'm fairly certain we're not using themes, so I should be able to safely remove  ~\Content\kendo\2016.3.118\Black - ~\Content\kendo\2016.3.118\Uniform and all themese in between? Do I need to keep the Images or textures folder?  What about ~\Scripts\kendo\2016.3.1118\cultures? Or ~\Scripts\kendo\2016.3.1118\messages?

 

Marin Bratanov
Telerik team
 answered on 27 Jan 2017
1 answer
284 views

Stack overflow (SO) has a pretty good discussion of the database operations that have to be performed in order to persist user defined row order based on their sortable interactions with grid.

http://stackoverflow.com/questions/330482/best-way-to-save-a-ordered-list-to-the-database-while-keeping-the-ordering

The domain I am working in is the 1-many data design for Master/Detail or Container/Element relationships in SQL server.  The master and detail records have identity keys and the detail record foreign keys to the master.

My take away is that the display order can be persisted in two ways.

1-1 persistence data

  • Extra field in the detail record: DisplayIndex
  • Separate table Sortable<for_detail_table> having only Detail_ID and DisplayIndex

This SO answer indicates three database operations are required to maintain the sortable state on a per sortable change event basis

1-many persistence data as a comma separated list of detail values, constructed from either the detail ids or some other unique over the detail records of a master

  • Extra field in the master record: DetailOrderingCSV
  • Separate table SortableCSV<for_master_table> having only Master_ID and DetailOrderingCSV

This SO answer calls this approach pragmatic, and this answer talks about separate tables

I was wondering if anyone has an example VS solution demonstrating remote persistence of sortable ordering.

Also would like to hear other ideas.

Pavlina
Telerik team
 answered on 27 Jan 2017
2 answers
172 views

Hello all,

This is more of a general question so I have opted to not include too much code with this question.  I can provide more if it will help find a good solution.

I have an existing tab layout where the tabs link to asp:panels in the page that in turn render a TabStrip and a Grid below:

                        Html.RenderAction("GetTabStrip", new RouteValueDictionary { { ..., ...} });
                        Html.RenderPartial("Grid", Model["Grade"], new ViewDataDictionary(this.ViewData) { { "gridName", "..." }, { "dsReadAction", "..." } });

The tab layout basically serves as a TabStrip before we adopted the ASP.NET MVC flavour of Telerik.  I have two such tabs in this layout that both render a TabStrip and Grid like above.

 

The first TabStrip works great - I am able to scroll horizontally (since there are a lot of tabs), and the content is shown as expected.  But the second TabStrip does not scroll and the content does not show up.  The k-tabstrip-items list elements seem to be different between the two TabStrips.  Here is an li element from the first TabStrip:

   <li class="k-item k-state-default" role="tab" aria-controls="tabstrip-2"><span class="k-loading k-complete"></span><a class="k-link" href="#tabstrip-2">New York - i really hope the scrolling works</a></li>

...and from the second TabStrip:

   <li class="k-item k-state-default" ><a class="k-link" href="#tabstrip-2">New York - i really hope the scrolling works</a></li>

...so the second element is missing the following attributes and span tag:

role="tab" aria-controls="tabstrip-2"><span class="k-loading k-complete"></span>

 

I believe this could be the source of my issues, but I am unsure if this implementation will even work.

 

Thanks for reading - any feedback is appreciated.

Julian Houlding
Top achievements
Rank 1
 answered on 27 Jan 2017
24 answers
5.5K+ views
Hi All,

I have a Kendo grid which Displays data based on filter criteria in TextBox above clicking search button. The grid has edit and Detail Action links which take user to a different view (no popup or inline),  loading more fields than we Display in grid for edit.When done editing and user Comes back to grid it must retain old filter criteria, selected record, page etc. Which is the best way to achieve this using Kendo grid?

Anamika
Dimo
Telerik team
 answered on 26 Jan 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?