Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
136 views

as refer to another post for adding a checkbox in groupheader,

http://www.telerik.com/community/forums/aspnet-ajax/general-discussions/radgrid-checkbox-for-specific-group.aspx

i had implemented the code from

https://github.com/telerik/aspnet-sdk/tree/master/Grid/GroupingAndSelection

it works fine that it can select all child checkbox when click groupheader checkbox.
but i found that the groupheader checkbox cannot deselect after click. i had gone through the code many time but cannot solve it.

Thanks.

<script type="text/javascript" language="javascript" >
    function Clicked(strKey) {
        alert(strKey);
    }
 
 
    var tree = {
        isRoot: true
    },
           treePositionsCache = {};
 
    // The idea is to build a tree in which every node has a relation to it's parent group item
    function GridCreated(sender, args) {
        var rows = sender.get_masterTableView().get_element().rows,
               currentRow,
               currentNode = tree,
               shouldGoUpOneLevel = false,
               groupLevel = 1;
        //Builds the tree
        for (var i = 0; i < rows.length; i++) {
            currentRow = rows[i];
            if (currentRow.parentNode.tagName.toLowerCase() === "tbody") {
                //The row is a group header row
                if (currentRow.className.indexOf("rgGroupHeader") !== -1) {
                    //Finds the parent node of the current node
                    if (shouldGoUpOneLevel) {
                        for (var j = 0; j < groupLevel - $telerik.getElementsByClassName(currentRow, "rgGroupCol").length + 1; j++) {
                            currentNode = currentNode.parent;
                        }
                    }
                    //Determines the group level
                    groupLevel = $telerik.getElementsByClassName(currentRow, "rgGroupCol").length;
                    currentNode.numberOfItems++;
                    currentNode = currentNode[i] = {
                        //Sets the parent reference
                        parent: currentNode,
                        //Sets the checkbox reference
                        checkbox: $telerik.findElement(currentRow, "ClientSelectColumnSelectCheckBox") ||
                               $telerik.findElement(currentRow, "GroupHeaderCheckBox"),
                        numberOfItems: 0,
                        numberOfCheckedItems: 0
                    };
                } else {
                    // The row is a GridDataItem
                    shouldGoUpOneLevel = true;
                    // Increase the number of item that the parent has.
                    currentNode.numberOfItems++;
                    //If the item is selected mark it as one.
                    if (currentRow.className.indexOf("rgSelectedRow") !== -1) {
                        currentNode.numberOfCheckedItems++;
                    }
                }
                //Add the node to the tree
                treePositionsCache[i] = currentNode;
            }
        }
    }
 
 
    function RowSelected(sender, args) {
        PerformSelect(treePositionsCache[$get(args.get_id()).rowIndex]);
    }
 
    function RowDeselected(sender, args) {
        PerformDeselect(treePositionsCache[$get(args.get_id()).rowIndex], true);
    }
 
    //Recursively traverse the tree and deselect the check boxes
    function PerformDeselect(node, firstCall) {
        if (--node.numberOfCheckedItems !== node.numberOfItems && !node.isRoot && node.checkbox.checked) {
            node.checkbox.checked = false;
            PerformDeselect(node.parent, false);
        }
    }
 
    //Recursively traverse the tree and select the check boxes
    function PerformSelect(node) {
        if (++node.numberOfCheckedItems === node.numberOfItems) {
            node.checkbox.checked = true;
            PerformSelect(node.parent);
        }
    }
 
    //Called when a group header check box is checked or unchecked
    function GroupToggleSelection(sender) {
        //Finds the row
        var row = Telerik.Web.UI.Grid.GetFirstParentByTagName(sender, "tr"),
        //Obtains the row index
               rowIndex = row.rowIndex,
        //Determines the group level
               level = $telerik.getElementsByClassName(row, "rgGroupCol").length,
               masterTable = $find('<%=RadGrid1.ClientID%>').get_masterTableView(),
               rows = masterTable.get_element().rows,
               isChecked = sender.checked;
        sender.checked = !sender.checkbox;
 
        //Traverses the rows from the current header down and selects or deselects the GridDataItems
        for (var i = rowIndex + 1; i < rows.length; i++) {
            //If we encounter a grop header with the same group level we stop the selection/deselection
            if (rows[i].className.indexOf("rgGroupHeader") !== -1) {
                if ($telerik.getElementsByClassName(rows[i], "rgGroupCol").length === level) {
                    break;
                }
            } else if (isChecked) {
                masterTable.selectItem(rows[i]);
            } else {
                masterTable.deselectItem(rows[i]);
            }
        }
    }
 
   </script>


<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="ldsPayrollFlow" AllowMultiRowSelection="True"
                GridLines="None" Width="960px" AllowSorting="True"
        AutoGenerateColumns="False" AllowFilteringByColumn="True"
                AllowPaging="True" PageSize="15" EnableAJAX="true"
        EnableAJAXLoadingTemplate="true" LoadingTemplateTransparency="25"
        CellSpacing="0">
 
                <PagerStyle Mode="NumericPages"></PagerStyle>
              
                <MasterTableView DataSourceID="ldsPayrollFlow" DataKeyNames="SID" GroupLoadMode="Client">
                    <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                    <RowIndicatorColumn>
                        <HeaderStyle Width="10px"></HeaderStyle>
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn>
                        <HeaderStyle Width="10px"></HeaderStyle>
                    </ExpandCollapseColumn>
 
                    <GroupByExpressions>                                              
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="DisplayName" FieldName="DisplayName" HeaderText="Staff Name"></telerik:GridGroupByField>
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="DisplayName" ></telerik:GridGroupByField>
                        </GroupByFields>                        
                        </telerik:GridGroupByExpression>
 
                    </GroupByExpressions>
                    <GroupHeaderTemplate>
                            <asp:CheckBox ToggleType="CheckBox" ID="GroupHeaderCheckBox" OnClick="GroupToggleSelection(this);" runat="server"></asp:CheckBox>
                    </GroupHeaderTemplate>
 
                    <Columns>
                            <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" Visible="TRUE" HeaderStyle-Width="10" Display="false">
                            </telerik:GridClientSelectColumn>
                        <telerik:GridBoundColumn DataField="SID" HeaderText="SID" ReadOnly="True"
                            SortExpression="SID" UniqueName="SID" Visible=false>
                        </telerik:GridBoundColumn>

Joe
Top achievements
Rank 1
 answered on 26 Sep 2013
7 answers
120 views
Iam Facing issue(creating dynamic column with filtertemplate in radcomboboxes in rad grid )
  
We are using radgrid.We are generating dynamic columns with combobox in filter template .We are generating Column dynamically.
  
Issue is Combobox selected changed event is not woring. 
  
i am doing this programmatically using ITEMPLATE interface by inheriting in a class and calling InstantiateIn method using Creating combox control.
Naga
Top achievements
Rank 1
 answered on 26 Sep 2013
3 answers
209 views
Hi, 
I want to call a javascript function when user clicks hierarchy expand button. my hierarchyloadmode = serverondemand and i don't want to change to  hierarchyloadmode = client because i takes very long time to load radgrid. in addition my telerik version doesn't support HierarchyLoadMode.Conditional

is there any solution? 
Kostadin
Telerik team
 answered on 26 Sep 2013
3 answers
171 views
Click on the same date two times gives NULL value second time.
How do I get away with it, so I get the same value even if I click the same date more than once?

Try: http://demos.telerik.com/aspnet-ajax/calendar/examples/programming/serversideevents/defaultcs.aspx
Changed Date to: "9/30/2013 12:00:00 AM"
Changed Date to: "none"
Shinu
Top achievements
Rank 2
 answered on 26 Sep 2013
4 answers
139 views
how can i have a grid with a image collumn binded image from database
Jayesh Goyani
Top achievements
Rank 2
 answered on 26 Sep 2013
6 answers
215 views
I am using RadSchduler, In which before using UpdatePanel, onappointmentcommand works well. But when I use UpdatePanel it never calls the event (when I insert / cancel) an Appointment. 
 
Any kind of help is fine. 
 
Following is the code I am using 
 
 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
          <ContentTemplate><telerik:RadScheduler ID="RadScheduler1" runat="server"
      SelectedView="MonthView" Skin="WebBlue"
      onappointmentcommand="RadScheduler1_AppointmentCommand1"
       onload="RadScheduler1_Load" DataKeyField="ID" DataSubjectField="Subject"
      DataStartField="Start" DataEndField="End"
      onappointmentdelete="RadScheduler1_AppointmentDelete" AllowEdit="false" Height="600px">
 
        <InlineInsertTemplate>
            <asp:DropDownList runat="server" ID="ddlAgenTeamLst" DataSourceID="objTeam" DataTextField="name" DataValueField="id"></asp:DropDownList>
            <asp:Button ID="btnInsert" runat="server" CommandName="Insert" Text="Insert"/>
            <asp:Button ID="btnCancel" runat="server" CommandName="Cancel" Text="Cancel"/>
        </InlineInsertTemplate>
</telerik:RadScheduler></ContentTemplate>  </asp:UpdatePanel>
 
In the above onAppointmentDelete is working fine in both the cases. But I need to get the value from the drop down list when I Insert a data, So i am unable to use "OnAppointmentInsert".
Mohan Prasath
Top achievements
Rank 1
 answered on 26 Sep 2013
2 answers
155 views
Hi,
In my functionality I am adding some appointments(data) in the back end based if one specific appointment is added. (through UI). I am here using RadScheduler1_AppointmentCommand method to Insert the appointments. But even if I use Rebind or DataBind , the newly added appointment are not reflected in the UI. Only one appointment(that is included through UI) is displayed. So what should I have to do to update the new changes?

Note: I am using Scheduler inside UpdatePanel
Mohan Prasath
Top achievements
Rank 1
 answered on 26 Sep 2013
3 answers
135 views
Hi support Telerik,
I have the problem as following :
- I use Telerik.Web.UI dll version 2011.2.915.35 and use RadAjaxManager and RadAjaxLoadingPanel to run Ajax.
- I have a button when click this button then it will run Ajax
The first time I click button it seem run everything ok, but the second time I click button then I see an issue javascrippt error as following:
  Object doesn't support this property or method at code line : if($telerik.$(b).css("filter").indexOf("opacity")!=-1||$telerik.$(b.firstChild.nextSibling).css("filter").indexOf("opacity")!=-1)
My environment use IE8 with https and windows server 2008. Please hepl me resolve this issue ?
Thank you so much.
John Avata.
Pavlina
Telerik team
 answered on 25 Sep 2013
5 answers
233 views
Hi,

As per my client requirement i need to implement Radscheduler in MVC razor engine.
Firstly i want to know, is it possible or not ? If yes can any one guide me with sample example if possible.

Thanks,
Nag...
Darin
Top achievements
Rank 1
 answered on 25 Sep 2013
6 answers
524 views
I have several people that do pasting from Word in to RadEditors. When they do, they get a dialog box:

The content you are trying to paste has MS Word formatting.Would you like to clean it?

They are given two options, which are OK and Cancel. When you click OK, everything's fine. When you click cancel, text still pastes in. I assume that this is because Cancel in this case means "no, I do not want to clean it, just paste it in." Am I correct?

If so, here's the real issue: we do not want people to able to bypass this cleaning (basically, force them to click OK every time). I assume it's possible to force it with Javascript, but I need to know which event is fired in this case. Is it OnClientPasteHtml? (http://www.telerik.com/help/aspnet-ajax/editor-onclientpastehtml.html)

Thanks,
Chris Aumiller
Marin Bratanov
Telerik team
 answered on 25 Sep 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?