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

OnItemCreated not called

3 Answers 26 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Sandeep
Top achievements
Rank 1
Sandeep asked on 21 Aug 2014, 10:07 AM

Hi Team,

I am using treelist. I am binding data to treelist and calling below method

<ClientSettings>
                            <ClientEvents OnItemDeselected="ReviewerAssignmentList_OnItemDeselected"  OnItemSelected="ReviewerAssignmentList_OnItemSelected"
                                 OnItemCreated="ReviewerAssignmentList_OnItemCreated" />
                            <Selecting AllowItemSelection="true" UseSelectColumnOnly="true" />
                            <Scrolling AllowScroll="true" ScrollHeight="431px" UseStaticHeaders="true" />
                        </ClientSettings>

Data is binded to treelist.

And in method ReviewerAssignmentList_OnItemCreated

function ReviewerAssignmentList_OnItemCreated(sender, args) {               
                alert('1');               
            }

It is not called method ReviewerAssignmentList_OnItemCreated, but If I click anywhere on page this method is called and displays alert.

Could any body help me on this, so that alert is displayed when rows are created.

Regards
Sandy

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 21 Aug 2014, 12:16 PM
Hi Sandeep,

The provided information is not enough to replicate the issue. The OnItemCreated event of RadTreeList will fire when each of the TreeListDataItem client components is created. Note that the RadTreeList client TreeListDataItem objects will not be created until they are requested, for example by calling TreeListInstance.get_dataItems(). Until then, the OnItemCreated client event of the control will not fire. Please have a look into this online demo for knowing the working of client side events of RdaTreeList.

Thanks,
Princy.
0
Sandeep
Top achievements
Rank 1
answered on 22 Aug 2014, 12:37 PM
Hi Princy,

I have a RadToolbar and TreeList.

When I bind the data to treelist, select a row.

And click on radtoolbar button "Update", then the selected row in displayed in editable mode.

but the child items of selected row are not selected by default.

<telerik:RadToolBar ID="ReviewerObjectToolBar" runat="server" Enabled='<%# EnableToolBar()%>' OnClientButtonClicking="onReviewerToolBarClicking"
                        OnButtonClick="ReviewerObjectToolBar_Click" ToolTip='<%#ScopeToolTip %>' BorderStyle="None"
                        Width="100%" Height="28px">
                        <Items>
                            <telerik:RadToolBarButton ImageUrl="~/client/Images/4x_rediscover.png" Value="Rediscover"
                                Enabled='<%# EnableRediscoverButton %>' ToolTip='<%# RediscoverToolTip%>' CommandName="Rediscover" />                             
                            <telerik:RadToolBarButton ImageUrl="~/client/Images/edit.png" Value="btnUpdateSelectedClick"
                                Enabled="false" CommandName="UpdateSelected"  />
                            <telerik:RadToolBarButton ImageUrl="~/client/Images/Save.png" Value="btnSaveClick"
                                Text="Save" Visible="false" CommandName="SaveSelected"/>
                            <telerik:RadToolBarButton ImageUrl="~/client/Images/cancel1.png" Value="btnCancelClick"
                                Text="Cancel" Visible="false" CommandName="Cancel" />
                        </Items>
                    </telerik:RadToolBar>
<telerik:RadTreeList ID="ReviewerAssignmentList" runat="server" DataKeyNames="ObjectId" ClientDataKeyNames="AssignmentId" OnPreRender="RadTreeList_PreRender"
                        EditMode="InPlace" OnItemCreated="ReviewerAssignmentList_ItemCreated" AllowMultiItemSelection="True"
                        AllowLoadOnDemand="true" ParentDataKeyNames="ParentObjectId" Width="100%" AllowPaging="true" PageSize="15"
                        AllowMultiItemEdit="true" OnUpdateCommand="ReviewerAssignmentList_UpdateCommand" AllowSorting="true"
                        OnItemDataBound="ReviewerAssignmentList_ItemDataBound"
                        GridLines="Both" AutoGenerateColumns="false" OnNeedDataSource="ReviewerAssignmentList_NeedDataSource"  
                        OnChildItemsDataBind="ReviewerAssignmentList_ChildItemsDataBind" OnItemCommand="ReviewerAssignmentList_ItemCommand">
                        <HeaderStyle Height="33px"/>
                        <Columns></Columns>
                        <ClientSettings>
                            <ClientEvents OnItemDeselected="ReviewerAssignmentList_OnItemDeselected"  OnItemSelected="ReviewerAssignmentList_OnItemSelected"
                                 OnItemCreated="ReviewerAssignmentList_OnItemCreated" />
                            <Selecting AllowItemSelection="true" UseSelectColumnOnly="true" />
                            <Scrolling AllowScroll="true" ScrollHeight="431px" UseStaticHeaders="true" />
                        </ClientSettings>
                        <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" />
                    </telerik:RadTreeList>



<script type="text/javascript">
            function ReviewerAssignmentList_OnItemCreated(sender, args) {                 
                var id1 = args.get_item().get_dataKeyValue("AssignmentId");                
                if (Reviewerselected[id1] && id1 != -1) {
                    args.get_item().set_selected(true);
                    document.getElementById('<%=ReviewerEditableItem.ClientID%>').value = ".";
                }
            }

function ReviewerAssignmentList_OnItemSelected(sender, eventArgs) {
                var id = eventArgs.get_item().get_dataKeyValue("AssignmentId");
                if (!Reviewerselected[id] && id != -1 ) {
                    Reviewerselected[id] = true;
                    document.getElementById('<%=ReviewerEditableItem.ClientID%>').value = document.getElementById('<%=ReviewerEditableItem.ClientID%>').value + "," + id;
                }
            }

function ReviewerAssignmentList_OnItemDeselected(sender, eventArgs) {
                //var id = eventArgs.get_item().get_dataKeyValue("AssignmentId");
                //if (Reviewerselected[id]) {
                //    Reviewerselected[id] = null;
                //}

                var assignmentId = eventArgs.get_item().get_dataKeyValue("AssignmentId");
                var selectedRows = document.getElementById('<%=ReviewerEditableItem.ClientID%>').value;
                if (Reviewerselected[assignmentId]) {
                    Reviewerselected[assignmentId] = null;
                    var rplStr = ',' + assignmentId;
                    var intIndexOfMatch = selectedRows.indexOf(',' + assignmentId);
                    while (intIndexOfMatch != -1) {
                        // Relace out the current instance.                         
                        selectedRows = selectedRows.replace(',' + assignmentId, '');
                        // Get the index of any next matching substring.
                        intIndexOfMatch = selectedRows.indexOf(',' + assignmentId);
                    }
                    document.getElementById('<%=ReviewerEditableItem.ClientID%>').value = selectedRows;

                }
}
        </script>

Do I need to do something else also

Please help.

Regards,
Sandeep
0
Princy
Top achievements
Rank 1
answered on 29 Aug 2014, 11:41 AM
Hi Sandeep,

I guess you want to select a child node on selection of parent node and deselect also. Please have a look into this forum thread which discuss the same scenario.

Thanks,
Princy.
Tags
TreeList
Asked by
Sandeep
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Sandeep
Top achievements
Rank 1
Share this question
or