Telerik Forums
UI for ASP.NET MVC Forum
1 answer
1.9K+ views

Requirements:

1>I am using MVC kendo grid and I am trying to add select all/deselect check box to the header. I have javascript which does the logic of selecting & deselecting all the individual check boxes. I also want to select/deselect the header check box based on check boxes in the rows. Since during grid initialization grid rows are unknown, we cannot attach click event to the individual check boxes in the rows. we have to do that after data is bound to the grid.

2> I also wanted to maintain the state of the check boxes when user navigate through pages or do sorting. ( because of this paging & sorting is done on client side. Server operation is set to false) The javascript is working correctly.

Issues:

1> I’m calling this javascript in dataBound event of the grid as suggested here by telerik support. However dataBound event is getting fired on each page change and sort. As per the documentation here it should get fired when widget is bound to dataSource. So I tried dataSource’s requestEnd event, but requestEnd event is also getting fired on each page change & sort. AGAIN, as per the documentation here it should only get fire when remote service request is finished.

2>I also noticed, when I view the page source in browser the grid has rows only for that particular page. So my javascript only finds check boxes for that page only.

So how do I implement select all check box column that will select all the check boxes and also maintain the states across paging and sorting? can someone please show some examples

$(function () {
 
 
    $gridElement = $("#grid");
    var kendoGrid = $gridElement.data("kendoGrid");
    var dataSource = kendoGrid.dataSource;
     
    kendoGrid.bind("dataBound", function (e)
        {
            configureSelectCheckBoxes($gridElement)
        }
    )
 
    $("#btnSearch").click(function () {
        kendoGrid.dataSource.read();
        kendoGrid.refresh();
        kendoGrid.dataSource.page(1);
    })
 
     
    function configureSelectCheckBoxes(grid) {
        // attach click event to select all check box
        grid.find("thead input:checkbox").click(
            function () {
                grid.find("td input:checkbox").prop("checked", $(this).prop("checked"));
            }
         );
 
        // attach click event to individual check box
        grid.find("tbody input:checkbox").click(
               function () {
                   var checkedCount = grid.find("td input:checkbox:checked").length;
                   var totalCount = grid.find("td input:checkbox").length;
                   grid.find("th input:checkbox").prop("checked", checkedCount === totalCount);
               }
        );
    }
})

 

@(Html.Kendo().Grid<MVCPOC.Models.MyModel>()
            .Name("grid")
            .Columns(col =>
            {
                col.Bound(p => p.ModelID)
                    .ClientTemplate("<input class='chkbox' type='checkbox' value='#=ModelID#' />")
                    .HeaderTemplate("<input type='checkbox' id='selectAll' />")
                    .Width(30)
                    .Sortable(false)
                    .Filterable(false);               
                col.Bound(p => p.StateProvinceCode);               
                col.Bound(p => p.EmailAddress);
            })
            .AutoBind(false)
            .Pageable()
            .Sortable()
            .Scrollable(x => x.Height(300))
            .HtmlAttributes(new { style = "height:500px" })
            .DataSource(dataSource => dataSource
                .Ajax()
                .ServerOperation(false)
                .PageSize(20)
                .Read(read => read
                    .Action("GetData", "Grid")))
 
        )

 

 

 

Hristo Valyavicharski
Telerik team
 answered on 03 Jul 2015
2 answers
249 views

Hello All,

         I am just trying to see the code in the Kendo examples for diagram implementation that I have downloaded recently (Latest release telerik.ui.for.aspnetmvc.2015.2.624.commercial), But when I run the solution locally and browse the 'Editing' section of the diagram I do get the shapes and connections as in demo site but I am not able to add a new shape (or new rectangle) to the diagram. When I press the rectangle icon in tool bar I get a error in browser console as follows.

Chrome: kendo.all.min.js:68 Uncaught TypeError: Cannot read property 'gradient' of undefined)

FireFox: kendo.all.min.js:68:8298 TypeError: t is undefined

 Also other options in the tool bar are also not working.

 

Ron
Top achievements
Rank 2
 answered on 03 Jul 2015
3 answers
309 views

Hi,

 

I've a MVC ListView which was working perfectly until I've localized it to German. My resources are managed in Visual Studio's Resource Designer, the typical way I'd say. If any of these resources contains an umlaut and is used directly in the template, it will be converted to something like "&#246;". The unescaped hash sign breaks the template. I've tried several attempts to fix this issue, but none of them worked:

1.<script type="text/x-kendo-tmpl" id="recordLinesTemplate">
2.@Resources.Resources.BtnDeleteLine // "Zeile l&#246;schen"
3.@Resources.Resources.BtnDeleteLine.Replace('#', 'X') // "Zeile l&#246;schen"
4.@((Resources.Resources.BtnDeleteLine).Replace('#', 'X')) // "Zeile l&#246;schen"
5.@Resources.Resources.BtnDeleteLine.Replace("ö", "ö") // "Zeile l&amp;ouml;schen"
6.@WebUtility.HtmlEncode(Resources.Resources.BtnDeleteLine) // "Zeile l&amp;#246;schen"
7.</script>

Out of curiosity, I've tried to encode the umlaut directly in the resource, but the ampersand gets encoded as well.

Any ideas how to resolve this issue?

Beste Grüße with two umlauts,

   Carsten

dbCF
Top achievements
Rank 2
 answered on 03 Jul 2015
2 answers
75 views

When i delete a row from a grid in batch mode it is just removed and actioned on save changes.

Is there a way to configure the grid so the deleted rows remain on the grid (ideally greyed out) until changes are saved?

Graeme
Top achievements
Rank 1
 answered on 03 Jul 2015
1 answer
86 views

So, the basic premise of what I'm trying to accomplish is pulling data about the schedule of events from the Telerik Scheduler to use in other contexts. 

For example, let's say that I want to be able to call some MVC action and pass in all of the titles for the events that are scheduled for today.

Or, as another example, let's say that each event is assigned to an owner (this is an event for Employee1, this other event is for Employee2, etc.) I want to be able to display all of the dates for scheduled events for a certain employee in a custom HTML solution; something along the lines of what the Agenda view looks like, but NOT inside of the Scheduler view. 

Is there a way to pull the data from the Scheduler to do these things? One solution would be to just get the event data from the database and parse the info from there. However, this would obviously require a bunch of extra logic when it comes to recurring events and figuring out which days of the week in which months those recurring events would occur. I would like to avoid having to figure that stuff out since it the Telerik Scheduler is already handling that logic anyways. 

Vladimir Iliev
Telerik team
 answered on 03 Jul 2015
4 answers
288 views
Hi, I currently have a kendo grid bound to a tempdata item which is a list of objects, on delete i remove the item that is being deleted from the tempdata item list , how can i refresh the grid ?  I tried returning the partial view that the grid is in but the partial view renders in the entire page even though i have it in an ajax.beginform, basically how can I make the partial view that contains the grid referesh in the delete action of the grid?
Jim
Top achievements
Rank 1
 answered on 02 Jul 2015
1 answer
106 views

Hi,

I'm trying to use the Upload control on the chrome mobile emulator.

I can't get it to post the file back to the server.

The Upload control is a part of a form that contains multiple fields.

The user can upload a single file.

The action of the post receives a model with a property of type HttpPostedFileBase. I tried changing to an IEnumerable but it still doesn't work.

I tried both ajax and regular posts.

What am I doing wrong?

Dimiter Madjarov
Telerik team
 answered on 02 Jul 2015
1 answer
722 views

I am getting a warning in the browser console (Chrome) with kendo date picker.

 

I am not setting date format to "yyyy-MM-dd". I have even tried to set up date format in the cshtml page for the kendo date picker.

@(Html.Kendo().DatePickerFor(m => m.StartDate)
           .Name("StartDate")
           .Format("MM/dd/yyyy")
           .Value(Model.StartDate))

Is this a default date format with date pciker? How can I change it?

Georgi Krustev
Telerik team
 answered on 02 Jul 2015
3 answers
216 views

Is it possible to define the grid attributes/properties in the MVC controller rather than the view to simplify the view at all?  I am currently evaluating Kendo before deciding whether or not to migrate from Infragistics IgniteUI.  

Infragistics IgniteUI igGrid allows you to define a GridModel (their object type) instance in your controller and pass it to the View which allows a much simpler bit of syntax in the view similar to:

Controller code:

    Public Function IGGridModel() As Infragistics.Web.Mvc.GridModel

        Dim grdModel As GridModel = New Infragistics.Web.Mvc.GridModel.GridModel()

        With grdModel
             . ID = ....

            .columns ....

             etc, etc

         End With

         Return grdModel

    End Function

 

View Code:

   <div ....  whatever>

        @Html.Infragistics().Grid(Model.IGGridModel)
  </div>

 

 

Kiril Nikolov
Telerik team
 answered on 02 Jul 2015
1 answer
181 views

I need to check all the child checkboxes when I'll check the parent checkbox. For example, in the attached file I need to check all the checkboxes (11M, 11MPRICE, 15M, 23M....) when I'll click BINS. And another case is if all checkboxes are selected then parent checkbox should be checked automatically. How can I do these?

 

 Thanks in advance.

Alexander Popov
Telerik team
 answered on 02 Jul 2015
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
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
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
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
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?