Telerik Forums
Kendo UI for jQuery Forum
1 answer
327 views
Good morning everyone,

I am currently using a grid with a hierarchy where in the detail grid, I cannot get the page to render properly when I use checkboxes, that are in readonly mode, to be displayed in a column in the detail grid.  If I do not use the checkboxes, the page renders properly.  I am not sure what I am doing wrong in the detail grid.  I am currently using a licensed version of Kendo UI Complete for ASP.NET MVC (Q2 2012).

I am using "ClientTemplate" method call in the detail grid (the grid in the "WebsiteLanguagesTemplate" script block).  I tried to do many different things but still cannot get it to work

The following is my code:

@model IEnumerable<WebsiteViewModel>
 
@(Html.Kendo().Grid<WebsiteViewModel>()
    .Name("grdAllWebsites")
    .Columns(columns =>
    {
        columns.Bound(o => o.Id)
            .Visible(false);
        columns.Bound(o => o.Name)
            .Width(200);
        columns.Bound(o => o.Type)
            .Width(125);
        columns.Bound(o => o.IsActive)
            .Width(75)
            .Filterable(false)
            .HtmlAttributes(new { style = "text-align: center;" })
            .ClientTemplate("<input readonly='readonly' type='checkbox' disabled='disabled' name='chkIsActive_#=Id#' id='chkIsActive_#=Id#' #= IsActive? \"checked='checked'\" : \"\" # />");
        columns.Command(command =>
        {
            command.Edit().Text(" ");
            command.Destroy().Text(" ");
        })
            .HtmlAttributes(new { style = "text-align: center;" });
    })
    .ClientDetailTemplateId("WebsiteLanguagesTemplate")
    .DataSource(dataSource =>
    {
        dataSource.Ajax()
            .Model(model =>
            {
                // DataKey
                model.Id(o => o.Id);
            })
            .PageSize(15)
            .Read(read => read.Action("Read", "Websites"))
            .Update(update => update.Action("Read", "Websites"))
            .Destroy(destroy => destroy.Action("Read", "Websites"));
    })
    .Events(events =>
    {
        events.Edit("Grid.onEdit");
        events.Remove("Grid.onDelete");
    })
    .Pageable(paging =>
    {
        paging.Numeric(true)
            .Info(true)
            .PreviousNext(true)
            .Refresh(true)
            .Messages(message =>
            {
                message.Empty(AdminResource.Admin_Page_Websites_Grid_NoRecordMsg);
            });
    })
    .Sortable()
    .Filterable()
)
 
<script id="WebsiteLanguagesTemplate" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<WebsiteLanguageViewModel>()
        .Name("WebsiteLanguages_#=Id#")
        .Columns(columns =>
        {
            columns.Bound(o => o.Id)
                .Visible(false);
            columns.Bound(o => o.Name)
                .Width(200);
            columns.Bound(o => o.Code)
                .Width(50);
            columns.Bound(o => o.IsActive)
                .Width(75)
                .Filterable(false)
                .HtmlAttributes(new { style = "text-align: center;" });
                .ClientTemplate("<input readonly='readonly' type='checkbox' disabled='disabled' name='chkIsActive_#=Id#' id='chkIsActive_#=Id#' #= IsActive? \"checked='checked'\" : \"\" # />");
        })
        .DataSource(dataSource =>
        {
            dataSource.Ajax()
                .Model(model =>
                {
                    // DataKey
                    model.Id(o => o.Id);
                })
                .Read(read => read.Action("Read2", "Websites", new { websiteId = "#=Id#" }));
        })
        .Pageable(paging =>
        {
            paging.Enabled(false)
                .Refresh(false)
                .Messages(message =>
                {
                    message.Empty(AdminResource.Admin_Page_WebsiteLanguages_Grid_NoRecordMsg);
                });
        })
        .Sortable()
        .ToClientTemplate()
    )
</script>

I am struggling a bit on this and really need to have that checkbox column available in the detail grid.

Any help on this matter, is very much appreciated.  

Thank you so much for your help.
Sam
Top achievements
Rank 1
 answered on 11 Oct 2012
0 answers
74 views
I have a grid with expanding detailed row enabled and within the detailed row, I have a tabstrip (just like the demo) but instead of having another data grid inside one of the tabs, I opt to have a plain html table. However, in doing so the parent grid's table settings are applied to the plain html table. Mainly, the width is fixed and not automatically adjusted based on the content of the cell and even explicit width declaration doesn't override it. From what I read from other threads, setting "scrollable" to false in the parent grid does the trick but since this is just a plain html table, why can't I override this? I don't want to compromise by changing the parent grid as I do want it to be scrollable. I've tried setting table-layout to auto but that doesn't do anything. Any other CSS override I can apply to the plain html table to achieve this? Many thanks.

Update: turns out applying table-layout as inline works. The CSS I had in the CSS file was as followed:

.k-grid .k-detail-cell .gridtable {table-layout:auto;}

where gridtable is the class name I applied to the table. 

Did I miss something?
Steve
Top achievements
Rank 1
 asked on 11 Oct 2012
5 answers
1.3K+ views
Hello,
my project uses the code snippet from the following example to construct the kendo grid:
http://demos.kendoui.com/web/grid/editing-inline.html 

when clicking the "Edit" button to edit the "Units in Stock" value, i dont need to allow real numbers but only integers in the editor.
UnitsInStock: { type: "number", validation: { min: 0, required: true } }

What is the editor template do i need to append here to strict kendoUI grid input only integer values in this column?
Thank you!
Joshua
Top achievements
Rank 2
Iron
Veteran
Iron
 answered on 11 Oct 2012
0 answers
47 views
posting data in form tag using jquery-1.8.0. does not go to the server .any help on how to make it work with jquery.
prince
Top achievements
Rank 1
 asked on 11 Oct 2012
2 answers
138 views
My model has a property that is a collection.  The collection can have any number of codes.  eg CPT, Rev, ...  If CPT is present in the collection I would like its code to be put in a CPT column and the same for any other codes.

Here is an example of my json from my WebAPI.
{
Data: [
  {
     ServiceId: 1,
     BillingCode: "123456789",
     Description: "Broken Arm",
     ChargeAmount: 2.15,
     Department: null,
     Codes: [
         {
         CodeType: "CPT",
         CodeNumber: "1234"
         },
         {
         CodeType: "Rev",
         CodeNumber: "5555"
         }
    ]
  },
  {
    ServiceId: 2,
    BillingCode: "2",
    Description: "Broken Leg",
    ChargeAmount: 4.5,
    Department: null,
    Codes: [
       {
       CodeType: "HCPC",
       CodeNumber: "4543"
       }
    ]
  }
  ],
 Count: 2
}

I would like the columns to be:
Billing Code | Description | Charge Amount | Department | CPT | Rev | HCPC

        dataSource: new kendo.data.DataSource(
            {
                transport: {
                    read: "api/Codes"
                },
                pageSize: 5,
                serverPaging: true,
                schema:
                    {
                        data: "Data",
                        total: "Count"
                    }
            }),

Is what I have so far and I can get everything filled in except the codes.
Jesse
Top achievements
Rank 1
 answered on 11 Oct 2012
2 answers
113 views
Hi, I have been trying all kinds of tricks to get the 'create' working on my grid. Please find attached my Controller and View.

<!----------------------------------------------CONTROLLER------------------------------------------------------------------------>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using AttributeRouting.Web.Http;
using HomeBudget.Models;
using HomeBudget.ViewModels;


// ReSharper disable UnusedMember.Global
// ReSharper disable FieldCanBeMadeReadOnly.Local
namespace HomeBudget.Controllers
{
    public class ProductController : ApiController
    {
        IRepository _repository = new Repository();
        private HttpRequest _request = HttpContext.Current.Request;


        public Response Get()
        {
            int take = _request["take"] == null ? 10 : int.Parse(_request["take"]);
            int skip = _request["skip"] == null ? 0 : int.Parse(_request["skip"]);


            var products = (from p in _repository.GetAllItems<Product>()
                           select new ProductViewModel
            {
                ProductID = p.ProductID,
                ProductName = p.ProductName,
                CategoryName = _repository.GetLookupValue<Category>(info => info.CategoryID == p.CategoryID, info => info.CategoryName),
                //Category = p.Category,
                Discontinued = p.Discontinued
            }).Skip(skip).Take(take).ToArray();


            return new Response(products, _repository.GetAllItems<Product>().Count);
        }


        public Response Delete(Guid id)
        {
            try
            {
                var product = _repository.GetAllItems<Product>().SingleOrDefault(info => info.ProductID == id);
                _repository.Delete(product);
                _repository.SaveAllChanges();
                return new Response();
            }
            catch (Exception ex)
            {
                return new Response(string.Format("There was an error deleting object popup: custom editors", id.ToString(), ex.Message));
            }
        }
        
        [POST("api/product/create")]
        public Response Create()
        {
            try
            {
                var product = _repository.Create<Product>();
                return new Response(product);
            }
            catch (Exception ex)
            {
                return new Response("There was an error creating object popup: custom editors");
            }
        }


        [POST("api/product/{id}")]
        public HttpResponseMessage Post(Guid id)
        {
            var response = new HttpResponseMessage();
            try
            {
                var product = _repository.GetItemById<Product>(info => info.ProductID == id);
                if (product != null)
                {
                    product.ProductName = string.IsNullOrEmpty(_request["ProductName"]) ? product.ProductName : _request["ProductName"];
                    product.UnitPrice = _request["UnitPrice"] == null ? product.UnitPrice : Convert.ToDecimal(_request["UnitPrice"]);
                    _repository.SaveAllChanges();
                    response.StatusCode = HttpStatusCode.OK;
                }
                else
                {
                    response.StatusCode = HttpStatusCode.InternalServerError;
                    response.Content = new StringContent(string.Format("The employee with id popup was not found in the database", id.ToString()));
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = HttpStatusCode.InternalServerError;
                response.Content = new StringContent(string.Format("The database updated failed: popup", ex.Message));
            }
            return response;
        }
    }
}


<!----------------------------------------------PAGE------------------------------------------------------------------------>


<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="HomeBudget._Default" %>


<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<html>
<head>
    <title>Products</title>
    <link href="Content/kendo/2012.2.710/kendo.common.min.css" rel="stylesheet" type="text/css" />
    <link href="Content/kendo/2012.2.710/kendo.default.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="productGrid"></div>


    <script src="Scripts/jquery-1.8.2.js" type="text/javascript"></script>
    <script src="Scripts/kendo/2012.2.710/kendo.web.min.js" type="text/javascript"></script>
    
    <script type="text/javascript">


        $(function () {
            $("#productGrid").kendoGrid({
                editable: "inline",
                toolbar: ["create", "edit", "destroy"],
                pageable: true,
                selectable: "multiple cell",
                scrollable: false,
                navigatable: true,
                columns: [
                    { field: "ProductName", title: "Product" },
                    { field: "CategoryName", title: "Category" },
                    //{ field: "Category", title: "Category2", width: "150px", editor: categoryDropDownEditor, template: "#=Category.CategoryName#" },
                    { field: "UnitPrice", title: "UnitPrice" },
                    { field: "Discontinued", title: "Discontinued?" },
                    { command: ["edit", "destroy"], title: " " }
                ],
                dataSource: new kendo.data.DataSource({
                    transport: {
                        read: "api/product",
                        update: {
                            url: function (product) {
                                return "api/product/" + product.ProductID;
                            },
                            type: "POST"
                        },
                        destroy: {
                            url: function (product) {
                                return "api/product/" + product.ProductID;
                            },
                            type: "DELETE"
                        },
                        create: {
                            url: function () {
                                return "api/product/create";
                            },
                            type: "POST"
                        }
                    },
                    pageSize: 10,
                    serverPaging: true,
                    serverSorting: true,
                    schema: {
                        data: "Data",
                        total: "Count",
                        errors: "Errors",
                        model: {
                            id: "ProductID",
                            fields: {
                                ProductID: { editable: false, nullable: true },
                                PropductName: { editable: true, validation: { required: true} },
                                UnitPrice: { type: "number", editable: true, nullable: true },
                                Discontinued: { type: "boolean", editable: true, nullable: true },
                                CategoryName: { editable: true, nullable: true }
                                //Category: { editable: true, nullable: true }
                            }
                        }
                    },
                    error: function (e) {
                        alert("The action failed. Please consult the web master.");
                        this.cancelChanges();
                    }
                }),
                change: function (e) {
                    var product = this.dataSource.getByUid(this.select().data("uid"));
                    console.log(product.ProductID);
                },
                parameterMap: function (options, operation) {
                    if (operation !== "read" && options.models) {
                        return { models: kendo.stringify(options.models) };
                    }
                }
            });
        });
        
        function categoryDropDownEditor(container, options) {
            var data = [
                { text: "Food", value: "3F3CC554-5577-412D-BF12-6161E6198181" },
                { text: "Toiletries", value: "3F3CC554-5577-412D-BF12-7161E6198181" }
            ];
            $('<input data-text-field="CategoryName" data-value-field="CategoryID" data-bind="value:' + options.field + '"/>')
                .appendTo(container)
                .kendoDropDownList({
                    autoBind: false,
                    dataSource: data,
                    dataTextField: "text",
                    dataValueField: "value"
                });
        }
    </script>
</body>
</html>
</asp:Content>



Please help.
Jon
Top achievements
Rank 1
 answered on 11 Oct 2012
5 answers
897 views
Hi,

Anyone know how to resizing window of popup editor?
like resizing width and height.
Nohinn
Top achievements
Rank 1
 answered on 11 Oct 2012
1 answer
133 views
has anyone else come across the issue of filtering on a Custom Editor Column?

Following This Editor Example, after trying to add a filter, i notice that you can't filter on the column.
Daniel
Telerik team
 answered on 11 Oct 2012
1 answer
101 views
My Banks dropdownlist is populated, but once I select a bank, it never fires the JsonResult of the Accounts dropdown.  I feel like I'm doing exactly what the demos are, but I must be missing something.  Any Help would be greatly appreciated.

My Popup Template.cshtml:

<table id="table">
    <tr>
        <td>
            Bank
        </td>
        <td>
            @(Html.Kendo().DropDownList()
          .Name("banks")
                  .OptionLabel("-- Select Item --")
          .DataTextField("BankName")
          .DataValueField("BankId")
          .DataSource(source => {
               source.Read(read =>
                               {
                                   read.Action("GetCascadeBanks", "Home");
                               });
          })

                  ) 
        </td>
    </tr>
    <tr>
        <td>
            Account
        </td>
        <td>
            <script>
                function filterAccounts() {
                    return {
                        banks: $("#banks").val()
                    };
                }
            </script>
           
            @(Html.Kendo().DropDownList()
          .Name("accounts")
                  .OptionLabel("-- Select Item --")
          .DataTextField("AccountName")
          .DataValueField("AccountID")
          .DataSource(source => {
              source.Read(read =>
              {
                  read.Action("GetCascadeAccounts", "Home")
                      .Data("filterAccounts");
              })
              .ServerFiltering(true);
          })
          .Enable(false)
          .AutoBind(false)
          .CascadeFrom("banks")
                  )
        </td>
    </tr>
</table>


HomeController:

public JsonResult GetCascadeBanks()
        {
            var ortbanks = from bank in db.ORTBanks
                           orderby bank.BankName

                           select new TreasuryCreateItem()
                                      {
                                          BankID = bank.BankID,
                                          BankName = bank.BankName,
                                      };

            return Json(ortbanks, JsonRequestBehavior.AllowGet);
        }

        public JsonResult GetCascadeAccounts(int banks)
        {
            var ortaccounts = from account in db.ORTAccounts
                              where account.AccountName != string.Empty
                           orderby account.AccountName

                           select new TreasuryCreateItem()
                           {
                               AccountID = account.AccountID,
                               AccountName = account.AccountName,
                           };

            var accountsInBank = from p in ortaccounts where p.BankID == banks select p;

            return Json(accountsInBank, JsonRequestBehavior.AllowGet);
        }



Alex
Top achievements
Rank 1
 answered on 11 Oct 2012
0 answers
72 views
I use incell edit mode.
Can I add a row with out focus on it?

For example I want to add a row when I edit another row, and I want to continue editing.
Alex
Top achievements
Rank 1
 asked on 11 Oct 2012
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
Date/Time Pickers
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Application
Map
Drag and Drop
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
SPA
Filter
Drawing API
Drawer (Mobile)
Globalization
Gauges
Sortable
ModalView
Hierarchical Data Source
Button
FileManager
MaskedTextBox
View
Form
NavBar
Notification
Switch (Mobile)
SplitView
ListBox
DropDownTree
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
ColorPicker
Pager
Styling
MultiColumnComboBox
Chat
DateRangePicker
Dialog
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
OrgChart
TextBox
Effects
Accessibility
ScrollView
PivotGridV2
BulletChart
Licensing
QRCode
ResponsivePanel
Switch
Wizard
CheckBoxGroup
TextArea
Barcode
Breadcrumb
Collapsible
Localization
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
Popover
DockManager
FloatingActionButton
TaskBoard
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
BottomNavigation
Ripple
SkeletonContainer
Avatar
Circular ProgressBar
FlatColorPicker
SplitButton
Signature
Chip
ChipList
VS Code Extension
AIPrompt
PropertyGrid
Sankey
Chart Wizard
OTP Input
SpeechToTextButton
InlineAIPrompt
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?