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

[Solved] Selectable row

4 Answers 164 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
jfhandfield
Top achievements
Rank 1
jfhandfield asked on 27 Aug 2010, 02:19 PM
I'm trying to convert my grid to a selectable row instead of a button but it doesn't seem to work and I have no clue why. Could someone point me out where is my problem pls. Right now the grid is getting created correctly but I just can't select anything!

<% using (Html.Configurator("Filtrer par ...")
              .PostTo("Filtering", "User")
              .Begin())
   {%>
<p>
    <label for="contains">
        <strong>
            <%:SharedViewRessources.Name%></strong>
        <%:SharedViewRessources.Contains%></label>
    <%:Html.TextBox("contains", "")%>
</p>
<button class="t-button t-state-default" type="submit">Appliquer</button>
<% } %>
<%: Html.Telerik().Grid(Model)
    .Name("Usagers")
    .DataKeys(keys => keys.Add(c => c.UserId))
    .Columns(columns =>
    {
        columns.Bound(c => c.UserId).Width(45).Filterable(false);
        columns.Bound(c => c.FirstName).Width(200);
        columns.Bound(c => c.LastName).Width(200);
        columns.Bound(c => c.Email);
        columns.Bound(c => c.LastLogin).Width(180).Filterable(false);
    })
    .DataBinding(dataBinding => dataBinding.Ajax().Select("_SelectionClientSide_Customers",
                "User"))
    .Pageable(paging => paging.PageSize(20))
    .Scrollable(scrolling => scrolling.Height(350))
    .Sortable()
    .Selectable()
    .Filterable(filtering => filtering
        .Filters(filters => filters
           .Add(o => o.FirstName).Contains((string)ViewData["contains"] ?? string.Empty)))
    .ClientEvents(events => events.OnRowSelected("onRowSelected"))
    .RowAction(row => row.Selected = row.DataItem.UserId.Equals(ViewData["id"]))
%>


Thank you

4 Answers, 1 is accepted

Sort by
0
jfhandfield
Top achievements
Rank 1
answered on 28 Aug 2010, 03:57 AM
Ok So I managed to narrow down my problem to the ClientEvents

As soon as I add that .ClientEvents( e => e.OnRowSelected("blahblah")
the selection does work anymore.

Here's my code again

    <%:
        Html.Telerik().Grid(Model)
        .Name("Usagers")
        .DataKeys(keys => keys.Add(c => c.UserId))
        .Columns(columns =>
        {
            columns.Bound(c => c.UserId).Width(45).Filterable(false);
            columns.Bound(c => c.FirstName).Width(200);
            columns.Bound(c => c.LastName).Width(200);
            columns.Bound(c => c.Email);
            columns.Bound(c => c.LastLogin).Width(180).Filterable(false);
        })
        .Sortable()
        .Pageable(paging => paging.PageSize(20))
        .Scrollable(scrolling => scrolling.Height(350))
        .Sortable()
        .Selectable()
        .Filterable(f => f
            .Filters(filters => filters
                .Add(o => o.FirstName).Contains((string)ViewData["contains"] ?? string.Empty)))
        .ClientEvents(e => e.OnRowSelected("OnRowSelected"))
         
    %>
    <div class="FormActionButtonContainer">
        <%: Html.CustomLinkButton(SharedViewRessources.User_Create, Url.Action("Create", "User"))%>
    </div>
 
    <script type="text/javascript">
        function onRowSelected(e) {
            var newLoc = 'User/Edit/' + e.row.rowid;
            document.location.href = newLoc;
        
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HtmlHead" runat="server">
<%:
    Html.Telerik().StyleSheetRegistrar()
                  .DefaultGroup(group => group
                  .Add("telerik.common.min.css")
                  .Add("telerik.simple.min.css")
                  .Add("telerik.windows7.min.css")
                  .Combined(true)
                  .Compress(true))
%>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Scripts" runat="server">
<%
    Html.Telerik().ScriptRegistrar()
                  .DefaultGroup(group => group.Combined(true)
                  .Compress(true))
                  .Render();
%>
</asp:Content>

Thank you for the help!
0
jfhandfield
Top achievements
Rank 1
answered on 30 Aug 2010, 09:15 PM
Can any admin let me know what I'm doing wrong here cause I clearly don't understand the reason behind all this!

Thxs!
0
Binu
Top achievements
Rank 1
answered on 11 Oct 2010, 10:29 PM
0
John
Top achievements
Rank 1
answered on 14 Oct 2010, 12:42 AM
The problem looks like you have "OnRowSelected" as the function name which you bind to and "onRowSelected" as the actual function name.  The function needs a capital 'O'

John
Tags
Grid
Asked by
jfhandfield
Top achievements
Rank 1
Answers by
jfhandfield
Top achievements
Rank 1
Binu
Top achievements
Rank 1
John
Top achievements
Rank 1
Share this question
or