Telerik Forums
Kendo UI for jQuery Forum
6 answers
831 views
I have a grid in which I want to bind the generated columns inside the foreach-loop (currently set to "Number") to the dictionary entry of e.Key. The code below works, but I have the problem that I need the sorting functionality of the column menu to sort by the dictionary entry. In the current code I get the Bound "Number" as field to sort by, but I need the dictionary key.
 
@(Html.Kendo().Grid<Bauteil>()
                .Name("PartSearchGrid")
                .Resizable(resize => resize.Columns(true))
                .Sortable()
                .ClientDetailTemplateId("detailtemplate")
                .PersistSelection(true)
                .Selectable(selectable => selectable
                .Type(GridSelectionType.Row)
                .Mode(GridSelectionMode.Single)
                )
                .ToolBar(tools =>
                {
                    tools.Custom().Text("<input id='partsearchbox' onkeyup='onSearch()' placeholder='" + GuiLabel["Label_Search"].Value + "' />");
                    tools.Excel();
                    tools.Custom().Text("Reset").HtmlAttributes(new { onclick = "resetFilter()" });
                })
                .Pageable(pageable => pageable
                .PageSizes( new[] { 10, 20, 50, 100, 500, 1000 })
                .Enabled(true)
                .Numeric(true)
                )
                .Scrollable(s => s.Virtual(GridVirtualizationMode.Rows))
                .Columns(columns =>
                {
                    columns.Bound(p => p.Number).Width(100);
                    columns.Bound(p => p.Name).Width(100);
                    columns.Bound(p => p._calcNoOfProcesses).Width(100);
 
                    foreach (Meta_PlanningProfileEntry e in Model.Part_Profile_Entries)
                    {
                        columns.Bound("Number").ClientTemplate("# if (PlanningDataDict[\"" + e.Key + "\"] != null) { #" + "<p>#= PlanningDataDict[\"" + e.Key + "\"] #</p>" + "# } else { #" + "" + "# } #").Width(100);
                    }
                    columns.Bound(p => p.StateString).Width(100);
                })
                .Excel(excel => excel
                .FileName("TP_Parts_Export.xlsx")
                .AllPages(true)
                )
                .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(50)
                .ServerOperation(true)
                .Model(model =>
                {
                    model.Id(m => m.ID);
                })
 
                .Read(r => r.Action("Parts_Read", "Part").Data("getPartFilters"))
                )
                .ColumnMenu()
                )
Tsvetomir
Telerik team
 answered on 08 May 2020
7 answers
174 views

Hello Everyone,

I'm using kendo.ui.Window in my project which is run on mobile,

the window widget default is opened as maximum, it's perfect when the device is vertical,

but when I rotate the device to horizontal, sometimes it work fine, but sometimes the window widget is not full fill the screen, it will display like this

https://drive.google.com/open?id=1Wgl81bXRdFSwtSU5lebVWdNSoiAZajPH

is it possible to solve this problem programmatically?

 

here is my code: 

var myWindow = $('#chart-dialog');
myWindow.kendoWindow({
    width: 450,
    title: "QC Trend Chart - Test No:",
    visible: false,
    closable: false,
    modal: false,
    content: '',
    actions: [
        "Close"
    ],
});

 

Thanks for your help !!

David
Top achievements
Rank 1
 answered on 08 May 2020
3 answers
149 views

Trying to disable worksheet tab reordering but no dice. I've tried listening for dragstart using jquery as well as attaching kendoDraggable to the .k-item elements of my spreadsheet but drag event's don't seem to be raised when reordering tabs. 

 

                $("ul.k-tabstrip-items .k-item").kendoDraggable({
                    dragstart: function (e) {
                        return false; //tried e.preventDefault() as well
                    },
                    dragend: function (e) {
                        return false;
                    }
                });

Any suggestions would be appreciated.

Petar
Telerik team
 answered on 07 May 2020
4 answers
1.2K+ views

 

 

 

 

 

 

 

this.taskGridOptions = {
        data: self.tasks,
        scrollable: false,
        sortable: true,
        persistSelection: true,
        selectable: "row",
        change: function (grid) {
            console.debug("Change grid...");
            self.checkForCheckedRows();
        },
        dataBound: function () {

            this.table.find(".checked-row").click(function () {
                var checked = this.checked;
                var grid = $("#taskGrid").data("kendoGrid");
                // Find the row that was checked
                row = $(this).closest("tr"),

                    // Set the data item's IsSelected property
                    dataItem = grid.dataItem(row);
                dataItem.IsSelected = checked;

                var realItem = ko.utils.arrayFirst(self.tasks(), function (item) {
                    if (item.Id() == dataItem.Id) {
                        return true;
                    }
                });

                // And set it's IsSelected property (this field isn't bound)
                if (realItem)
                    realItem.IsSelected = checked;

                // Update the text alerting how many have been checked
                self.checkForCheckedRows();

                // debug
                console.debug(JSON.stringify(self.tasks()));
            });
        },
        noRecords: {
            template: "<div class='no-grid-data'> 'No records found, please refine your search.'</span>"
        },
        pageable: {
            pageSize: 20
        },
        columns: [
            {
                headerTemplate: "<input id='check-all-box', type='checkbox', class='check-box' />",
                field: "IsSelected",
                type: "boolean",
                width: 45,
                sortable: false,
                template: "<input type='checkbox' class='checkbox checked-row' />",
            },
            { field: "Id", title: "Task Id" },
            { field: "TicketId", title: "Ticket Ref" },
            { field: "LeadId", title: "Lead Id" },
            {
                field: "UserId", title: "User",
                template: function (data) {
                    return self.getUsernameByUserId(data.UserId);
                }
            },
            {
                field: "ResultCodeId", title: "Result Code",
                template: function (data) {
                    return self.getResultcodeById(data.ResultCodeId);
                }
            },
            {
                field: "DueDate", title: "Due Date",
                template: function (data) {
                    return parseJsonDate(data.DueDate).toLocaleString();
                }
            },

            {
                field: "Status", title: "Task Status",
                template: function (data) {
                    if (data.Status == InteractionStatusType.Closed)
                        return "Closed";
                    else if (data.Status == InteractionStatusType.InProgress)
                        return "In Progress";
                    else if (data.Status == InteractionStatusType.Open)
                        return "Open";
                }
            },
            {
                field: "ChannelType", title: "Channel Type",
                template: function (data) {
                    if (data.ChannelType == InteractionTypes.Call)
                        return "Call";
                    else if (data.ChannelType == InteractionTypes.Email)
                        return "Email";
                    else if (data.ChannelType == InteractionTypes.Chat)
                        return "Chat";
                }
            },
            {
                command: { text: "View Details", click: showDetails, title: " ", width: "180px" },
            }
        ]
    }
    
    function wnd() {
        $("#details")
        .kendoWindow({
            title: "Customer Details",
            modal: true,
            visible: false,
            resizable: false,
            width: 300
        }).data("kendoWindow");
    }
    detailsTemplate = kendo.template($("#template").html());

    function showDetails(e) {
        e.preventDefault();

        var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
        wnd.content(detailsTemplate(dataItem));
        wnd.center().open();
    }

 

<script id="template" type="text/x-kendo-template">
    <div id="taskInfo-dialog">
        <label class="form-label">
            Subject:
            <span>#=Description#</span>
        </label>
        <label class="form-label">
            Notes:
            <span>#=Notes#</span>
        </label>
    </div>
</script>

Plamen Mitrev
Telerik team
 answered on 06 May 2020
10 answers
3.2K+ views
I'm using this to add template in toolbar of kendo ui mvc grid.

.ToolBar(toolbar =>{
                toolbar.Template(@<text>
                        ...
                    </text>);
                })

I can also use this to add a default excel export button:
.ToolBar(toolbar => toolbar.Excel())

Is it possible to add the excel export button, then add template (buttons) after excel button?

or, we will have to use one template button and export excel file in code?


Thanks
Silviya Stoyanova
Telerik team
 answered on 05 May 2020
2 answers
4.7K+ views

Hi 

I am looking for some help . I need to get a pop up window if I click the cell in the grid. In simpler words ,The user should get a pop up grid when he clicks on the particular cell in a grid .

I have tired the on row select event but that is allowing me to click the whole row but I need a particular cell to be clicked on. And how to I bind my grid to the pop up window after selecting the cell in the grid. Any example would be appreciated.

 

Thanks in Advance.

 

 

Georgi
Telerik team
 answered on 05 May 2020
2 answers
124 views

I have a table of medical data, and a filter for each of the columns. I am trying to filter the autosuggestions of the second filter (the one for the description), so that it only suggests items which match the already input Area. If you check out this CodePen it probably makes more sense: https://codepen.io/thomasfarleigh/pen/dyYVbRd

 

If you enter 'Lip' into the Area input, you will see that the autosuggestions available for the Description are Neoplasm, and Tumor cells which is perfect, as they are two descriptions that match Lip. However if you enter 'Base of tongue' into the area input, the only autosuggestion you get is 'Something different' and not Neoplasm which is also a match for Base of tongue.

 

I'm really can't figure out why this is happening. Is the filter function already associating Neoplasm with Lip even though it matches both items? Would appreciate any guidance.

 

I am using this function which gets called by the dataBound event:
function filterAutoCompleteDataSource(e) {
  var gridFilter = e.sender.dataSource.filter();
  $("#grid").data("kendoGrid").thead.find('span[data-field="HistologyBehaviorDescription"] input[data-role="autocomplete"]').data().kendoAutoComplete.dataSource.filter(gridFilter);
}

Nikolay
Telerik team
 answered on 05 May 2020
3 answers
893 views

I have a grid that has a detail template that contains a tabstrip which contains a further grid, along the lines of what is described in the previous forum post Grid with Tabstrip with Grid - Server Binding. This shows hierarchical data, with the child data being of the same type as the parent data.

I have a Kendo ContextMenu defined which I use to show a context menu with dynamically created and manipulated items on the rows in the parent grid. This works great. (The manipulation is enabling/disabling menu items based on flags hidden in the selected data rows). However I want to show the same context menu on the rows in the child grids, obviously the selected menu option should apply to the selected rows in the child grid.

 

How can I achieve this? Currently when I right click on a selected row in the child grid I still get the context menu for the parent grid. Is there a way to define a context menu but have the target set according to which grid selected rows the user right clicked on? I've got a simplified sample below that shows the approach I've used, I'm open to options or suggestions using either a Razor/server approach or using some javascript/jQuery magic.

 

 

001.@using (Html.BeginForm("Index", "Home"))
002.{
003.    Html.Kendo()
004.        .Grid(Model.Files)
005.        .Name("ParentDataGrid")
006.        .Columns(columns => {
007. 
008.            columns.Bound(df => df.ExternalId)
009.                    .HtmlAttributes(new { id = "externalId" })
010.                    .Hidden(true)
011.                    ;
012. 
013.            columns.Bound(df => df.OptionFlags)
014.                    .HtmlAttributes(new { id = "flags" })
015.                    .Hidden(true)
016.                    ;
017. 
018.            columns.Bound(df => df.Reference)
019.                    .Title("Reference")
020.                    ;
021. 
022.            columns.Bound(df => df.SourcedDate)
023.                    .Title("Submitted Date")
024.                    .Format("{0:dd/MM/yy}")
025.                    ;
026. 
027.            columns.Bound(df => df.FileName);
028.        })
029. 
030.        .DetailTemplate(dt =>
031.              Html.Kendo()                                           
032.                  .TabStrip()                                          
033.                  .Name("Tabstrip." + dt.Id)
034.                  .Items(items => {
035.                      items.Add()
036.                          .Text("Child files")
037.                          .Content(
038.                                      @<text>
039.                                          @(Html.Kendo()
040.                                              .Grid<DataFile>()
041.                                              .Name(string.Format("childFileGrid_{0}", dt.ExternalId))
042. 
043.                                              .Columns(columns => {
044.                                                                      columns.Bound(col => col.FileName)
045.                                                                            .Title("File name")
046.                                                                            ;
047.                                                                      columns.Bound(col => col.SourcedDate)
048.                                                                            .Title("Created")
049.                                                                            .Format("{0:dd/MM/yy HH:mm:ss}")
050.                                                                            ;
051.                                                                  })
052.                                              .DataSource(ds => ds.Ajax()
053.                                                                  .Read(read => read.Action("GetChildFiles", "Home")
054.                                                                                      .Data(string.Format(@"{{parentFileId:""{0}""}}", dt.Id))
055.                                                                                      )
056.                                                                  )
057.                                          )
058.                                          @(
059.                                              //this (attempted) context menu is not appearing at all
060.                                              Html.Kendo()
061.                                                  .ContextMenu()
062.                                                  .Name(string.Format("childFileGridContextMenu_{0}", dt.ExternalId))
063.                                                  .Target(string.Format("#childFileGrid_{0}", dt.ExternalId))
064.                                                  .Orientation(ContextMenuOrientation.Vertical)
065.                                                  .Items(i => {
066.                                                                  i.Add().Text("Test entry");
067.                                                              })
068.                                                  .Events(ev =>   {
069.                                                                      ev.Open("childFileContextMenuOpened");
070.                                                                  })
071.                                          )
072.                                      </text>
073.                              );
074. 
075.                  })
076.                  .Render()
077.                  )
078.        .DataSource(ds => ds
079.                            .Server()
080.                            .Model(model => model.Id(df => df.ExternalId))
081.                            )
082.        .Render();
083. 
084. 
085. 
086. 
087.}
088. 
089.     
090.    @(
091.        //this is the parent grid context menu, this is the only context menu that is appearing
092.        Html.Kendo()
093.            .ContextMenu()
094.            .Name("parentDataContextMenu")
095.            .Target("#ParentDataGrid")
096.            .Orientation(ContextMenuOrientation.Vertical)
097.            .Items(items => items.Add())
098.            .Events(ev =>   {
099.                                ev.Open("parentFileContextMenuOpened");
100.                            })
101.    )
102. 
103.<script>
104. 
105.    function parentFileContextMenuOpened(e) {
106.        debugger;
107.        var parentGrid = $("#ParentDataGrid").data("kendoGrid");
108.        dataContextMenuOpened(e, parentGrid);
109.    }
110. 
111.    function childFileContextMenuOpened(e) {
112.        //currently this doesn't get called...
113.        debugger;
114.        var childGrid = $("#????????").data("kendoGrid");
115.        dataContextMenuOpened(e, childGrid);
116.    }
117. 
118.    function dataContextMenuOpened(e, targetGrid) {
119.        if ($(e.item).is("li"))
120.            return;
121. 
122.        //debugger;
123. 
124.        var selectedRows = targetGrid.select();
125. 
126.        var rejectRows = getCanRejectRows(selectedRows);
127.        var approveRows = getCanApproveRows(selectedRows);
128.        var unrejectRows = getCanUnrejectRows(selectedRows);
129.        var canRejectRowsFlag = rejectRows.length > 0;
130.        var canApproveRowsFlag = approveRows.length > 0;
131.        var canUnrejectRowsFlag = unrejectRows.length > 0;
132. 
133. 
134.        debugger;
135.        var menuItems = [
136.                              {
137.                                   text: "Status"
138.                                  ,items:   [
139.                                                  { text: "Reject",     enabled: canRejectRowsFlag }
140.                                                , { text: "Approve",    enabled: canApproveRowsFlag }
141.                                                , { text: "Unreject",   enabled: canUnrejectRowsFlag }
142.                                            ]
143.                              }
144.                            //, { cssClass: "k-separator", enabled: false }
145.                        ];
146. 
147.        //this.setOptions({ dataSource: menuItems });
148.        e.sender.setOptions({ dataSource: menuItems });
149.    }
150. 
151. 
152.    function getRowsBySpecifiedFlag(selectedRows, flagValue) {
153.        return selectedRows .find("#flags")
154.                            .filter( function (index)   {
155.                                                            //debugger;
156.                                                            return (Number($(this).text()) & flagValue) == flagValue;
157.                                                        } );
158.    }
159. 
160.    function getCanRejectRows(selectedRows) {
161.        return getRowsBySpecifiedFlag(selectedRows, 1 << 2);
162.    }
163. 
164.    function getCanApproveRows(selectedRows) {
165.        return getRowsBySpecifiedFlag(selectedRows, 1);
166.    }
167. 
168.    function getCanUnrejectRows(selectedRows) {
169.        return getRowsBySpecifiedFlag(selectedRows, 1 << 3);
170.    }
171. 
172.</script>

 

Happyat1
Top achievements
Rank 1
 answered on 04 May 2020
3 answers
565 views

Hi,

I am trying to fire an event on "createChild" click. Below is my code sample.

I have an "Actions" column and there are 2 commands (Add Child and Delete) specified under this column. I want to call a javascript function when user clicks on "add child" image to set "id" to the newly created row. But the "createChild" function never gets executed. Is there something I am doing wrong here?  

columns : [
        {
title : "Actions", 
headerAttributes : {
style : "text-align:center;"
},
command : [
{
name : "createChild",
text : " ",
className : "btn-details",
imageClass : "fas fa-folder-plus fa-lg",
click : createChild
},
{
name : "destroy",
text : " ",
className : "btn-details",
imageClass : "icon icon-delete"
}],
width : 120
},

Nikolay
Telerik team
 answered on 04 May 2020
1 answer
112 views
my Requirement is NumericText Box should allow numbers as follow:- 009876543221 and having spinners to increase and decrease numbers and should allow negative numbers in my textbox
Nikolay
Telerik team
 answered on 04 May 2020
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?