Telerik Forums
UI for ASP.NET MVC Forum
2 answers
6.8K+ views
Hello,
I am looking for information on how to add a dropdown box to an MVC specific grid control. I need the box to display in a cell and show when the grid is rendered. Do you know of a sample or have example code available?

Thanks 
Viktor Tachev
Telerik team
 answered on 29 Sep 2017
1 answer
915 views

Hi, I'm trying to get this: http://demos.telerik.com/aspnet-mvc/grid/detailtemplate

except I don't need the tabstrip. So what I want is just the grid. Is that possible because when I try to do this with just a grid, I get an empty row with no data.

Thanks,
Jokull

Georgi
Telerik team
 answered on 29 Sep 2017
4 answers
350 views

Hi, I am trying to customize my mvc grid, here is the image https://ufile.io/6c1xf

1. No header, the columns.bound to customize instead of c.name

2. How to put edit and delete into 1 column?

3. How to call javascipt in string not integer?

 


@(Html.Kendo().Grid<iOneDistribution.Web.Models.Users.UserViewModel>()
      .Name("grid")
      .Columns(columns =>
      {

           //1. header must be able to customize.

           //3.  it doesn't call the datagrid as this must be in string not integer
           columns.Bound(c =>
             c.Name).ClientTemplate(
                      "<a style='cursor:pointer' onclick='getEditView('#=UserCode#');' " +
            ">EDIT</a>").Width("90");

         //  2. it is in the other column, i want to put into 1 column with the edit

         columns.Command(command =>
          {
              command.Destroy().Text(" ");
          }).Width(100);
          columns.Bound(c => c.Name);
          columns.Bound(c => c.Email);
          columns.Bound(c => c.MobilePhone);
          columns.Bound(c => c.OfficePhone);
          columns.Bound(c => c.HomePhone);
          columns.Bound(c => c.UserPosition);
          columns.Bound(c => c.IsSalesPerson);
          columns.Bound(c => c.IsPurchaser);
          columns.Bound(c => c.IsActive);
          columns.Bound(c => c.IsAllowApprove);
          columns.Bound(c => c.DefaultCulture);
      })
      .Pageable()
      .Sortable()
      .Filterable()
      .Scrollable()
      .DataSource(dataSource => dataSource
          .Ajax()
          .PageSize(20)
          .Model(model => model.Id(u => u.UserCode))
          .Read(read => read.Action("Users_Read", "Users"))
          .Destroy(update => update.Action("Destroy", "Users"))
      )
)

<script type="text/javascript">
    function getEditView(id) {
        alert(id);
        $.post("@Url.Action("ShowEdit", "Users")", {id: id}, function(data) {
            if (data) {
                $('#EditDiv').append(data);
            }
        });
    }
</script>
Stefan
Telerik team
 answered on 29 Sep 2017
3 answers
1.0K+ views

Hello,

 

My Kendo menu has 3 items. First is an Icon , second is a text "Adress suchen" and third is another Icon with Sub menuitems. Using following Stylesheet i could achieve partially but i cannot Center align the text of manu. Also the left side Icon is outside the menu width.

@(Html.Kendo().Menu()
.Name("menuImages")
.Items(items =>
{

items.Add().Text("<span class=\"k-icon k-i-menu\"></span> ").HtmlAttributes(new { id = "mnuMain" }).SpriteCssClasses("k-icon k-i-menu").Encoded(false)
.Items(children =>
{
.....
children.Add().Text("Alle Objekte Anzeigen");
});            
items.Add().Text("Adressen suchen").HtmlAttributes(new { id = "mnuTitle" }).ContentHtmlAttributes(new { @style = "text-align:middle;" });
items.Add().Text("<span class=\"k-icon k-i-grid\"></span> ").HtmlAttributes(new { id = "mnuHome" }).SpriteCssClasses("k-icon k-i-grid").Encoded(false);


})

My css is

ul.k-widget.k-menu-horizontal > .k-item
{
float: right;
}
#menuImages > .k-last {
float: left;
width:40px;
}

So i want both Icon items left and right aligned and middle one text Center aligned

Thanks

 

Anamika

Neli
Telerik team
 answered on 28 Sep 2017
1 answer
1.0K+ views

Hi,

In button click event inside the script will call $("#grd").data("kendoGrid").dataSource.read(); 

script for Grid databound

function onDefaultSelect(e) {
    
    var rows = e.sender.tbody[0].rows;
    $(rows).each(function (e) {
        var grid = $("#grd").data("kendoGrid");
        var row = this;
        var dataItem = grid.dataItem(row);        
        grid.select(row);
    });    
    var getValue = this.selectedKeyNames().join(",");
}

When I button click  the selectedKeyName value is getting correct. When I button click again, the selectedkeyvalue is not changed, it getting old value. Is there any missing script ??

Regards

Suman

Stefan
Telerik team
 answered on 28 Sep 2017
1 answer
287 views

How to include filter options in the header template for a grid when exporting to PDF. For example, if user has filtered a grid column by say username = 'John', I need to change the header template to contain the text 'Sorted by username: John' in the PDF header.

The filter options should only be displayed in the exported files and not in the webpage. Can it be implemented in both - JavaScript and asp.net?

Stefan
Telerik team
 answered on 28 Sep 2017
2 answers
754 views

Hello there guys, i need your help. i have a batch edit grid view. And when i click on particular cell, i get the correct column name  of the clicked cell as long as the grid is un-grouped. When i group the columns in the grid, the name are all wrong.

Here is my grid

01.@(Html.Kendo().Grid<P2I_UI.Models.ViewM.Plan>()
02.    .Name("PlanGrid")
03.    .Columns(columns =>
04.    {
05.        columns.Group(ScriptGroup => ScriptureGroup
06.               .Title("<center>Scripture</center>")
07.               .Columns(dd =>
08.               {
09.                   dd.Bound(e => e.MaterialCategory).Title("Type").Width(110).HtmlAttributes(new { @style = "text-align:center; font-weight:normal; font-size:80%" }).ClientTemplate("#=MaterialCategory.ShortName#").Sortable(false);
10.                   dd.Bound(e => e.Product).Title("Item No").Width(130).HtmlAttributes(new { @style = "text-align:center; font-weight normal; font-size:80%" }).ClientTemplate("#=Product.ItemNumber#").Sortable(false);
11.                   dd.Bound(e => e.ProductName).Title("Description").Width(160).HtmlAttributes(new { @style = "text-align:center; font-weight normal; font-size:80%" });
12.               })
13.        );
14.        columns.Bound(c => c.ProjectEOYInventoryAssigned).Title("Proj.<br>EOY Inv<br>Assgnd").Width(71).HeaderHtmlAttributes(new { style = "text-align:right; font-weight: normal; font-size:85%" }).HtmlAttributes(new { @style = "text-align:right; font-weight:normal; font-size:80%" }).Format("{0:,#}");
15.        columns.Group(OuterGrantQuantity => OuterGrantQuantity
16.              .Title("<center>Grant Quantity</center>")
17.              .Columns(ogq =>
18.              {
19.                  ogq.Bound(e => e.Quarter1).Title("Q1").Width(95).HtmlAttributes(new { @style = "text-align:right; font-weight: normal; font-size:80%" }).Format("{0:,#}");
20.                  ogq.Bound(e => e.Quarter2).Title("Q2").Width(95).HtmlAttributes(new { @style = "text-align:right; font-weight: normal; font-size:80%" }).Format("{0:,#}");
21.                  ogq.Bound(e => e.Quarter3).Title("Q3").Width(95).HtmlAttributes(new { @style = "text-align:right; font-weight: normal; font-size:80%" }).Format("{0:,#}");
22.                  ogq.Bound(e => e.Quarter4).Title("Q4").Width(95)..HtmlAttributes(new { @style = "text-align:right; font-weight: normal; font-size:80%" }).Format("{0:,#}");
23.              })// end of the column
24.        );
25.columns.Bound(e => e.TotalGrantedRequest).Title("Tot.<br>Granted<br>Req").Width(72).HtmlAttributes(new { @style = "text-align:right; font-weight:normal; font-size:80%" }).Format("{0:,#}");
26.        columns.Bound(e => e.StandardCostPerUnit).Title("Cost<br>Per Unit").Width(72)..HtmlAttributes(new { @style = "text-align:right; font-weight:normal; font-size:80%" }).Format("{0:c}");
27.        columns.Bound(e => e.EstimatedGrantedCost).Title("Est.<br>Granted<br>Cost").Width(73)..HtmlAttributes(new { @style = "text-align:right; font-weight: normal; font-size:80%" }).Format("{0:c0}");
28.        columns.Bound(e => e.TotalNumberNeeded).Title("Tot.<br>Number<br>Needed").Width(75).HtmlAttributes(new { @style = "text-align:right; font-weight: normal; font-size:80%" }).Format("{0:,#}");
29.        columns.Command(e => e.Destroy().Text(" ").HtmlAttributes(new { @title = "Delete" })).Width(1);
30.    })
31.    .ToolBar(toolbar => { toolbar.Create(); toolbar.Save(); })
32.    .Editable(editable => editable.Mode(GridEditMode.InCell))
33.    .Events(events =>
34.    {
35.        events.Edit("onEditPlanGrid");
36.    })
37.    .Navigatable()
38.    .Sortable()
39.    .DataSource(dataSource => dataSource
40.        .Ajax()
41.        .Batch(true)
42.        .PageSize(30)
43.        .ServerOperation(false)
44.        .Model(model =>
45.        {
46.            model.Id(p => p.PlanScriptureID);
47.            model.Field(p => p.MaterialCategory).DefaultValue(ViewData["defaultMaterialCategory"] as P2I_UI.Models.ViewM.MaterialCategoryVM);
48.            model.Field(p => p.Product).DefaultValue(ViewData["defaultProduct"] as P2I_UI.Models.ViewM.ProductVM);
49.            model.Field(p => p.ProjectEOYInventoryAssigned);
50.            model.Field(p => p.TotalGrantedRequest).Editable(false);
51.            model.Field(p => p.StandardCostPerUnit);
52.            model.Field(p => p.EstimatedGrantedCost).Editable(false);
53.            model.Field(p => p.TotalNumberNeeded).Editable(false);
54.        })
55.        .Create("Script_Create", "Plan")
56.        .Read("Script_Read", "Plan")
57.        .Update("Script_Update", "Plan")
58.        .Destroy("Script_Delete", "Plan")
59.        .Events(e1 => e1.Change("onChange"))
60.    )
61.)
62. 
63.    function onEditPlanGrid(e) {
64. 
65.        var grid = $("#PlanGrid").data("kendoGrid");
66.        var fieldName = grid.columns[e.container.index()];
67. 
68.        console.log("this is fieldName:", fieldName)
69.        //if (fieldName === undefined) {
70.        //    e.sender.closeCell();
71.        //}
72.    }

 

How do i get the correct column name of the cell that was clicked?. Thank

 

Chinonso
Top achievements
Rank 1
 answered on 27 Sep 2017
1 answer
349 views

Hello,

I have two grids (#Grid1 and #Grid2) with a field "Column"
I need the field "Column" in the second grid to has a value less than a value from page.
According to this topic:
http://demos.telerik.com/aspnet-mvc/grid/editing-custom-validation
I just have to write "$.extend(true, kendo.ui.validator" and "a rule", but it will affect two grids
So a question sounds like: "How to write a validation rule that will affect only one grid in page?"

Georgi
Telerik team
 answered on 27 Sep 2017
1 answer
264 views

Hello,

 

In my Kendo mobile app in MobileLayout Header i want a Dropdown menu on right handside. To achieve this i am using MobileNavBar in Header and tried to put a menu inside. But it does not work. In attached Picture i have used a MobileButton inside navbar with 3 horizontal bar. So it Looks ok. Now when clicking on this button i want a Dropdown menu. is it achievable? If yes how. Here is my code so far

@(Html.Kendo().MobileView()
.Name("Adressen")
.Stretch(true)
.Layout("mobile-tabstrip")
.Content(@<text>
@AdressGrid()
</text>)
)

@(Html.Kendo().MobileLayout()
.Name("mobile-tabstrip")
.Header(obj => NavBarTemplate(this))
.Footer(
@<text>
@(Html.Kendo().MobileTabStrip()
.Items(items =>
{
items.Add().Text("Adresse").HtmlAttributes(new { @data_icon = "vendor-e" });
items.Add().Text("Sms").HtmlAttributes(new { @data_icon = "share" });
items.Add().Text("Detail").HtmlAttributes(new { @data_icon = "home" });
items.Add().Text("Home").HtmlAttributes(new { @data_icon = "home"});
items.Add().Text("Home").HtmlAttributes(new { @data_icon = "gps-e" });
})
)
</text>)
)

@helper NavBarTemplate(WebViewPage page)
{
@(Html.Kendo().MobileNavBar()
.Content(navbar =>
@<text>
@navbar.ViewTitle("Adressen")
@(Html.Kendo().MobileButton()
.Align(MobileButtonAlign.Right)
.HtmlAttributes(new { @class = "nav-button" ,@data_icon = "arrow-e"})
.Text(""))
</text>)
)

}

Thanks

 

Anamika

 

Veselin Tsvetanov
Telerik team
 answered on 27 Sep 2017
1 answer
1.0K+ views

Hi,

I want to use Grid ForeignKey column to choose objects by id.

The sample is in attachment. I want to make school column and grade column nullable, and I can set the value to null when I edit the row.

How to do this?

 

If I want to choose school column value by typing characters for filtering, is it possible to do this in Grid ForeignKey column? Or I have to use ClientTemplate to solve this problem? 

 

Because the sample file exceed the maximum size, I removed Telerik js/css files from the sample, please use version 2017.3.913

 

Georgi
Telerik team
 answered on 26 Sep 2017
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
Dialog
MultiColumnComboBox
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
Security
ColorPicker
DateRangePicker
Wizard
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?