Snippets Collections
buildComboDataSource: function (endpoint, sortField, pageSize) {
                return {
                    type: "odata-v4",
                    transport: {
                        read: {
                            url: this.odata.url() + endpoint,
                            dataType: "json",
                            xhrFields: {
                                withCredentials: true //needed for windows auth
                            }
                        }
                    },
                    schema: {
                        total: function (data) {
                            return data["@odata.count"];
                        }
                    },
                    pageSize: pageSize,
                    serverPaging: pageSize > 0 ? true : false,
                    serverFiltering: true,
                    serverSorting: true,
                    sort: {
                        field: sortField,
                        dir: "asc"
                    }
                };
            }
function grid_product_filter(element) {
    build_gridfilter(element, '/Products/GridFilterRead');
}


function build_gridfilter(element, url) {
   
    var combobox = element.kendoComboBox({

    placeholder: "Select",
    autoBind: true,
    filter: "contains",

        dataTextField: "Name",
        dataValueField: "Name",

        dataSource: {
            type: "aspnetmvc-ajax",
            sort: { field: "Name", dir: "asc" },
            transport: {
                read: {
                    url: url,
                }
            },
            schema: {
                data: "Data",
                total: "Total"
            },
            pageSize: 200,
            serverPaging: true,
            serverFiltering: true,
            serverSorting: true
        }
    });
    setdropdownwidth(combobox);
}
var standardfilterwidth = 300;
function setdropdownwidth(combobox) {
    if (combobox.data("kendoComboBox"))
        combobox.data("kendoComboBox").list.width(standardfilterwidth);
    else if (combobox.data("kendoExtendedComboBox"))
        combobox.data("kendoExtendedComboBox").list.width(standardfilterwidth);
}



function GridAddItemHandler(gridid) {
    var grid;

    if (gridid == undefined)
        grid = $("#grid").data("kendoGrid");
    else
        grid = $("#" + gridid).data("kendoGrid");
   
    if (grid) {

            grid.addRow();
        
    }
}
$(document).ready(function () {

    GridRowDoubleClickHandler();
  
}
                  
function GridRowDoubleClickHandler(gridid) {
    
        var grid;

        if (gridid == undefined)
            grid = $("#grid");
        else
            grid = $("#" + gridid);

        if (grid) {

            grid.delegate("tbody > tr", "dblclick", function () {
                var kendogrid = grid.data("kendoGrid");
                if (kendogrid.options.editable.mode == "popup") {
                    var row = $(this);
                    editrowdataitem = kendogrid.dataItem(row);
                    if (compliant) {
                        kendogrid.editRow(row);
                    }
                }
            });

            grid.delegate(".k-grid-edit", "click", function () {
                var kendogrid = grid.data("kendoGrid");
                if (kendogrid.options.editable.mode == "popup") {
                    var row = $(this).closest("tr");
                    editrowdataitem = kendogrid.dataItem(row);
                }
            });
        }

}
star

Wed Sep 22 2021 13:29:38 GMT+0000 (UTC)

#javascript #c# #telerik #kendo #mvc
star

Wed Sep 22 2021 13:23:11 GMT+0000 (UTC)

#javascript #kendo
star

Wed Sep 22 2021 13:20:59 GMT+0000 (UTC)

#javascript #kendo

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension