This question is locked. New answers and comments are not allowed.
Is there possible to set ClientTemplate with GridColumnSettings?
for exmple, I need to set a url link in specified columns or checkbox/dropdownlist, how to do that with the GridColumnSettings object?
What I know a way is using RowAction or CellAction, but I need to know the possibility to implement it by this way. this is my sample controller:
My View:
And also, the view got some problem: the page render accurate on first time visit,
but it was missing format while I click next page(In this case, the defined style is missing. How to improve the program?)
Thx for any advise.
for exmple, I need to set a url link in specified columns or checkbox/dropdownlist, how to do that with the GridColumnSettings object?
What I know a way is using RowAction or CellAction, but I need to know the possibility to implement it by this way. this is my sample controller:
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using ControlPayment.Models;using Telerik.Web.Mvc;using Telerik.Web.Mvc.Extensions;using Telerik.Web.Mvc.UI;namespace ControlPayment.Controllers{ public class MRInfoListController : Controller { // // GET: /MRInfoList/ public ActionResult Index(IDictionary<string, int> config_colwidth) { var columns = new[] { new GridColumnSettings { Member = "MRNo", Width = "245px", ClientTemplate = "<a href='" + <<
How to put the value of [Member] here?
>> + ">" + <<HOW TO PUT PUT VAULE OF [Member] herer?>> + + "</a>"
}, new GridColumnSettings { Member = "Cust", Width = "70px", Title = "Customer" }, new GridColumnSettings { Member = "PONo", Width = "130px" }, new GridColumnSettings { Member = "isVoid", Width = "40px", Title = "Void", ClientTemplate = "<input name='" + "<<HOW TO PUT THE [NAME OF Member] herer? >>" + "' type='checkbox' value='" + "<<HOW TO PUT VAULE OF [Member] here?>> " + "HOW TO PUT CHECK STATUS BASE ON VALUE OF [Member] HERE?" + "'>" }, }; //Set default Column configuration if (config_colwidth == null) { config_colwidth = new Dictionary<string, int> { {"GridWidth", 0}, }; //retreive column's width from pre-define array foreach (var col in columns) { int mywidth = Convert.ToInt32(col.Width.Replace("px", "")); config_colwidth.Add(col.Member, mywidth); } } //pass configuration data to view ViewData["config_colwidth"] = config_colwidth; ViewData["Columns"] = columns; return View(v_MRInfoRepository.All()); } [GridAction] public ActionResult _ColumnResizing() { return View(new GridModel(v_MRInfoRepository.All())); } }}<%@ Page Title="" Language="C#" UICulture="zh-TW" MasterPageFile="~/Views/Shared/FullScreen.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<v_MRInfoViewModel>>" %><asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> List Of MR Information</asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <% var config_colwidth = (IDictionary<string, int>)ViewData["config_colwidth"]; int i = 0; foreach (var setting in config_colwidth) { // Create a hiden for the key and value of each item in the dictonary %> <%= Html.Hidden("config[" + i + "].key", setting.Key) %> <%= Html.Hidden("config[" + i + "].value", setting.Value) %> <% i++; } //<button class="t-button t-state-default" type="submit">Save Column Widths</button> %> <% Html.Telerik().Grid(Model) .Name("MRInfoList") .ClientEvents(events => events.OnColumnResize("onMRInfoListResize")) .Columns(columns => columns.LoadSettings((IEnumerable<GridColumnSettings>)ViewData["Columns"])) .RowAction(row => { if (row.DataItem.isVoid == true || row.DataItem.Pending == true) { row.HtmlAttributes["style"] = "text-decoration:line-through;"; } }) .DataBinding(dataBinding => dataBinding.Ajax().Select("_ColumnResizing", "MRInfoList")) .Resizable(resizing => resizing.Columns(true)) .Scrollable(scrolling => scrolling.Height(620)) .Pageable(paging => paging.PageSize(20)) .Groupable() .Filterable() .Sortable().Render(); %></asp:Content><asp:Content ID="Content3" ContentPlaceHolderID="headContent" runat="server"></asp:Content><asp:Content ID="Content4" ContentPlaceHolderID="DescContent" runat="server"></asp:Content><asp:Content ID="Content5" ContentPlaceHolderID="FooterContent" runat="server"> <script type="text/javascript"> function onMRInfoListResize(e) { // update the hidden values which will be posted as IDictionary<string,int> var grid = $('#MRInfoList').data('tGrid'); $('#config_0__value').val(grid.$tbody.outerWidth()); var index = $.inArray(e.column, grid.columns) + 1; $('#config_' + index + '__value').val(e.newWidth); } </script></asp:Content>row.HtmlAttributes["style"] = "text-decoration:line-through;";Thx for any advise.