This is a migrated thread and some comments may be shown as answers.

Grid Selection Not Working

4 Answers 1245 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tracey
Top achievements
Rank 1
Tracey asked on 19 Jul 2013, 06:30 PM
Hello,  I have selectable() enabled in my code but it still won't work, I want to be able to select a row and have additional data from the entry to be displayed below the table. I've tried a few different ways and can't seem to get it to work. My code is: 

@(Html.Kendo()
        .Grid<SiteLogEntry>()
        .Name("Logs")
        .EnableCustomBinding(true)
        .Columns(c =>
            {
                c.Bound(p => p.LogId).Title("Log ID");
                c.Bound(p => p.ServerName).Title("Server Name");
                c.Bound(p => p.DateEntered).Title("Date Entered").Format("{0:MM/dd/yyyy h:m:ss tt}").Width("150px");
                c.Bound(p => p.DateLogged).Title("Date Logged").Format("{0:MM/dd/yyyy h:m:ss tt}").Width("150px");
                c.Bound(p => p.SourcePage).Title("Source Page");
                c.Bound(p => p.SourceObject).Title("Source Object");
                c.Bound(p => p.Description).Title("Description");
                c.Bound(p => p.ErrorMessage).Title("Error Message");
                c.Bound(p => p.AdditionalData).Title("Additional Data");
                c.Bound(p => p.Severity).Title("Severity");
            })
            .Resizable(resize => resize.Columns(true))
            .Sortable(s => s.Enabled(true))
            .Selectable(s => s.Enabled(true).Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
            .Scrollable()
            
            .Filterable(f => f.Enabled(true)
        .Extra(false)
        .Operators(operators => operators
            .ForString(str => str.Clear()
                .StartsWith("Starts with")
                .IsEqualTo("Is equal to")
                .IsNotEqualTo("Is not equal to")
            ))
        )   
            .HtmlAttributes(new { style = "height: 400px; width: 1500px; align: right;" })
            .Pageable(p => p.Enabled(true).Refresh(true))
            .DataSource(ds => ds
                .Ajax()
                .PageSize(10)
                .Read(read => read
                    .Action("GetLog", "SiteLog").Data("times"))
                    .Sort(z => z.Add(t => t.DateEntered).Descending())
                    )
            )


Nothing really changes whenever I enable/disable selectable. My end goal is to have the description, message, and data only show a small portion of their value within the table, then on selection populate a div below the table with their full entries. I've checked a number of the kendo demos but none have helped solve this issue.  Thanks for any help with this issue. 

4 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 22 Jul 2013, 01:41 PM
Hi Tracey,


If you would like to detect when the selection has changed, you should bind to the change event of the Grid, get the data for the currently selected row and display it in the div below.
E.g.
.Events(e => e.Change("change"))

function change(e) {
    var selected = this.select();
    var model = this.dataItem(selected);
    //custom actions
}

Please let me know if this was the information that you were looking for. 

 

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Tracey
Top achievements
Rank 1
answered on 22 Jul 2013, 04:53 PM
Hello Dimiter,
It seems like that might be along the lines of what I'm after but when I try to implement it gives the error: "Uncaught TypeError: Object [object Object] has no method 'select' "
when it tries to load the grid, so I never even have the opportunity to actually see if it selects or not.
0
Accepted
Dimiter Madjarov
Telerik team
answered on 23 Jul 2013, 12:03 PM
Hello Tracey,


Please make sure, that you have attached the change event handler to the Grid and not the dataSource (since they both have a change event and the auto-complete won't give an error).
E.g.
@(Html.Kendo().Grid<Order>()
    ...
    .Events(e => e.Change("change"))
    .DataSource(dataSource => dataSource
        ...
    )
)

Please let me know if that was the reason for the issue. If that is not the case, please send me a sample runnable project, where the issue is reproducing so I could assist you further.

 

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Tracey
Top achievements
Rank 1
answered on 24 Jul 2013, 04:22 PM
Hello Dimiter,
It looks like that did it, I can't believe I didn't think to change where the event handler was at. Thank you for your help.
Tags
Grid
Asked by
Tracey
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Tracey
Top achievements
Rank 1
Share this question
or