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

unexpected behavior for "select all" client side checkbox

2 Answers 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
vlad
Top achievements
Rank 1
vlad asked on 22 Dec 2011, 01:54 AM
Hi everybody

I have a strange situation when using telerik provided script for persisting client selected rows. This is the code :

function uxRadGrid_RowSelected(sender, arg) {
 
    //add rowKey to selection
    var rowKey = arg.getDataKeyValue("rowKey");
    if (!selected[rowKey]) {
        selected[rowKey] = true;
    }
}
 
function uxRadGrid_RowDeselected(sender, arg) {
 
    //remove rowKey from selection
    var rowKey = arg.getDataKeyValue("rowKey");
    if (selected[rowKey]) {
        selected[rowKey] = null;
    }
 
}
 
function uxRadGrid_RowCreated(sender, arg) {
 
    //select row if in selection
    var rowKey = arg.getDataKeyValue("rowKey");
    if (selected[rowKey]) {
        arg.get_gridDataItem().set_selected(true);
    }
}
 
function uxRadGrid_Created(sender, arg) {
    //nothing here
}

    <telerik:RadGrid ID="uxRadGrid" Skin="Transparent" AutoGenerateColumns="false" ShowHeader="true" Width="100%"
    OnNeedDataSource="uxRadGrid_NeedDataSource" OnItemCreated="uxRadGrid_ItemCreated" OnItemDataBound="uxRadGrid_ItemDataBound"
    PagerStyle-AlwaysVisible="true" PagerStyle-Mode="NumericPages" PagerStyle-Position="Bottom"
    AllowPaging="true" AllowMultiRowSelection="true" AllowSorting="true"
    runat="server">
        <MasterTableView ClientDataKeyNames="rowKey" TableLayout="Auto" GridLines="None">
            <Columns>
                <telerik:GridClientSelectColumn />
                <telerik:GridBoundColumn DataField="rowKey" HeaderText="Row Key" />
                <telerik:GridBoundColumn DataField="user_status" />
                <telerik:GridBoundColumn DataField="user_role" />
                <telerik:GridBoundColumn DataField="user_firstname" />
                <telerik:GridBoundColumn DataField="user_lastname" />
                <telerik:GridBoundColumn DataField="user_email" />
            </Columns>
 
            <SortExpressions>
                <telerik:GridSortExpression FieldName="rowKey" SortOrder="Ascending" />
            </SortExpressions>
        </MasterTableView>
 
        <ClientSettings>
            <ClientEvents OnRowCreated="uxRadGrid_RowCreated" OnRowDeselected="uxRadGrid_RowDeselected" OnRowSelected="uxRadGrid_RowSelected" OnGridCreated="uxRadGrid_Created" />
            <Selecting AllowRowSelect="true" />
        </ClientSettings>
    </telerik:RadGrid>

In my example, I use 3 data rows. The grid is ajaxified.

When I check 2 checkboxes in GridClientSelectColumn, and click on column header to sort items, everything works as expected but "check all" checkbox gets checked (even if only 2 of 3 items are selected) ! When I click on sort again, "check all" gets unchecked.

And when I select all 3 items, and sort, "check all" never gets checked after sorting. Same if I select only one item.

Am I missing something ?

Thanks

2 Answers, 1 is accepted

Sort by
0
vlad
Top achievements
Rank 1
answered on 23 Dec 2011, 04:04 PM
Never mind,

I will use a work-around. I just uncheck it every time with jquery in grid created event :

$("[id*='" + guid + "_uxRadGrid']").find(".rgCheck").children(":first").removeAttr("checked");
0
Milena
Telerik team
answered on 27 Dec 2011, 12:45 PM
Hello Vedran,

I can confirm that this is an unexpected behavior and I logged it in our tracking system. Our developers will perform further investigation and try addressing it. Meantime, you can use the workaround, which you are already found.

Regards,
Milena
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
vlad
Top achievements
Rank 1
Answers by
vlad
Top achievements
Rank 1
Milena
Telerik team
Share this question
or