Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
117 views
Hi,

I am testing out the Drag/Drop capabilities of the RadGrid (dragging from one grid to another), and I've come across a problem. It works great when the grid I'm dragging from has more than one row, but if there's one row I get the following JScript error thrown:

Microsoft JScript runtime error: Unable to get value of the property 'rows': object is null or undefined

Here's my ASPX markup:

    <script type="text/javascript">
 
        function OnClientUpdated(sender, args) {
            var message = "Update (check) was done!";
            var newMsgs = sender.get_value();
            if (newMsgs != 0) {
                sender.show();
                message += (newMsgs == 1) ? (" There is 1 new message!") : (" There are " + newMsgs + " new messages!");
            }
            else {
                message += " There are no new messages!";
            }
        }
         
    </script>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadScriptBlock runat="server" ID="scriptBlock">
 
        <script type="text/javascript">
                <!--
            function onRowDropping(sender, args) {
                if (sender.get_id() == "<%=RadGrid1.ClientID %>") {
                    var node = args.get_destinationHtmlElement();
                    if (!isChildOf('<%=RadGrid2.ClientID %>', node) && !isChildOf('<%=RadGrid1.ClientID %>', node)) {
                        args.set_cancel(true);
                    }
                }
                else {
                    var node = args.get_destinationHtmlElement();
                    if (!isChildOf('trashCan', node)) {
                        args.set_cancel(true);
                    }
                    else {
                        if (confirm("Are you sure you want to delete this order?"))
                            args.set_destinationHtmlElement($get('trashCan'));
                        else
                            args.set_cancel(true);
                    }
                }
            }
 
            function isChildOf(parentId, element) {
                while (element) {
                    if (element.id && element.id.indexOf(parentId) > -1) {
                        return true;
                    }
                    element = element.parentNode;
                }
                return false;
            }
                    -->
        </script>
 
    </telerik:RadScriptBlock>
     <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
         <telerik:RadSplitter ID="RadSplitter1" Width="100%" runat="server">
         <telerik:RadPane runat="server">
   <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="true"
                 onneeddatasource="RadGrid1_NeedDataSource" onrowdrop="RadGrid1_RowDrop">
   <MasterTableView AllowCustomSorting="true" AllowPaging="true" DataKeyNames="ID" AllowSorting="true" PageSize="20">
   
   </MasterTableView>
     <ClientSettings AllowRowsDragDrop="True" AllowColumnsReorder="true" ReorderColumnsOnClient="true">
                    <Resizing AllowColumnResize="true" />
                    <Selecting AllowRowSelect="True" EnableDragToSelectRows="false"/>
                    <Scrolling AllowScroll="true" UseStaticHeaders="true"/>
                          <ClientEvents OnRowDropping="onRowDropping" />
                </ClientSettings>
</telerik:RadGrid>     
         </telerik:RadPane>
         <telerik:RadSplitBar runat="server"></telerik:RadSplitBar>
         <telerik:RadPane runat="server">
   <telerik:RadGrid ID="RadGrid2" runat="server" AllowFilteringByColumn="true"
                 onneeddatasource="RadGrid2_NeedDataSource" onrowdrop="RadGrid2_RowDrop">
   <MasterTableView AllowCustomSorting="true" DataKeyNames="ID" AllowPaging="true" AllowSorting="true" PageSize="20">
   
   </MasterTableView>
     <ClientSettings AllowRowsDragDrop="True" AllowColumnsReorder="true" ReorderColumnsOnClient="true">
                    <Resizing AllowColumnResize="true" />
                             <ClientEvents OnRowDropping="onRowDropping" />
 
                    <Selecting AllowRowSelect="True" EnableDragToSelectRows="false"/>
                    <Scrolling AllowScroll="true" UseStaticHeaders="true"/>
                </ClientSettings>
</telerik:RadGrid>     
          
         </telerik:RadPane>
         
         </telerik:RadSplitter>
    
</telerik:RadAjaxPanel>
 
  <telerik:RadNotification ID="RadNotification1" runat="server" LoadContentOn="TimeInterval"
        Width="300" Animation="Fade" EnableRoundedCorners="true" EnableShadow="true"
        OnClientUpdated="OnClientUpdated" Title="Notifications" OffsetX="-20" OffsetY="-20"
        TitleIcon="none" UpdateInterval="10000" AutoCloseDelay="1500" OnCallbackUpdate="OnCallbackUpdate">
        <ContentTemplate>
            <asp:Literal ID="lbl" runat="server"></asp:Literal>
        </ContentTemplate>
    </telerik:RadNotification>

Here's my code behind:

public IList<Delivery> _Deliveries
        {
            get return (List<Delivery>)Session["Deliveries"]; }
            set { Session["Deliveries"] = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                _Deliveries = new List<Delivery>();
                _Deliveries.Add(new Delivery { ID = 1, Assigned = false, Customer = "Micross", TripDate = DateTime.Today });
                _Deliveries.Add(new Delivery { ID = 2, Assigned = false, Customer = "Test", TripDate = DateTime.Today });
                _Deliveries.Add(new Delivery { ID = 3, Assigned = false, Customer = "Micross3", TripDate = DateTime.Today });
                _Deliveries.Add(new Delivery { ID = 4, Assigned = false, Customer = "Test3", TripDate = DateTime.Today });
 
                RadGrid1.DataBind();
            }
        }
 
        private void BindMain()
        {
            RadGrid1.DataBind();
        }
 
        private void BindSecond()
        {
            RadGrid2.DataSource = _Deliveries.Where(a => a.Assigned == true);
            RadGrid2.DataBind();
        }
 
 
 
        protected void OnCallbackUpdate(object sender, RadNotificationEventArgs e)
        {
            int newMsgs = DateTime.Now.Second % 10;
            if (newMsgs == 5 || newMsgs == 7 || newMsgs == 8 || newMsgs == 9) newMsgs = 0;
            lbl.Text = String.Concat(new object[] { "You have ", newMsgs, " new invoices to process!" });
            RadNotification1.Value = newMsgs.ToString();
        }
 
        protected void RadGrid2_RowDrop(object sender, GridDragDropEventArgs e)
        {
                foreach (GridDataItem draggedItem in e.DraggedItems)
                {
                    var tmpOrder = _Deliveries.Where(a => a.ID == (long)draggedItem.GetDataKeyValue("ID")).Single();
                    tmpOrder.Assigned = false;
                }
 
                RadGrid1.Rebind();
                RadGrid2.Rebind();
           
        }
 
        protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            RadGrid1.DataSource = _Deliveries.Where(a => a.Assigned == false);
 
        }
 
        protected void RadGrid2_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            RadGrid2.DataSource = _Deliveries.Where(a => a.Assigned == true);
 
        }
 
        protected void RadGrid1_RowDrop(object sender, GridDragDropEventArgs e)
        {
 
                foreach (GridDataItem draggedItem in e.DraggedItems)
                {
                    var tmpOrder = _Deliveries.Where(a => a.ID == (long)draggedItem.GetDataKeyValue("ID")).Single();
                    tmpOrder.Assigned = true;
                }
                RadGrid1.Rebind();
                RadGrid2.Rebind();
          
        }

Thanks! 
Richard
Top achievements
Rank 1
 answered on 15 May 2012
5 answers
413 views
Hi all

I have a very wide grid, I am using Header Context Menu to Hide/Show the columns then I save the settings of the grid using GridSettingsPersister mentioned in the help.

My problem is that when I hide columns, save settings, and on the next time I load the settings and apply it on the grid, then I show some hidden columns(using header context menu, the grid does not resize, instead, with width of the other columns decreased. I used: TableLayout="Fixed", but It did not work. The width of the grid and master MasterTableView is calculated on GridSettingsPersister as follows:

            double totalWidth = 0; 
 
            foreach (GridColumn column in gridInstance.MasterTableView.Columns) 
            { 
                Triplet triplet = new Triplet(); 
                
                    triplet = dict[column.UniqueName]; 
                    Unit width = (Unit)triplet.Second; 
                    column.OrderIndex = (int)triplet.First; 
                    column.HeaderStyle.Width = width; 
                    column.Display = (bool)triplet.Third; 
 
                    if((bool)triplet.Third) 
                        totalWidth += width.Value;                    
                 
               
            } 
            gridInstance.Width = Unit.Percentage(totalWidth); 
            gridInstance.MasterTableView.Width = Unit.Percentage(totalWidth); 

Settings the width to 100% does not fix the issue, also leaving it empty.

Nilar
Top achievements
Rank 1
 answered on 15 May 2012
1 answer
369 views

I have two RadGrids, which are on different page(one is in base page another one in Overlay). Both are prepopulating and in first grid i have checkboxes for each row.


Now i want to add a new row in my second grid , based on the row selection of first grid means which rows checkboxes are checked.

Can anyone send me any sample code to do that. please Suggest.

Thanks.



Richard
Top achievements
Rank 1
 answered on 15 May 2012
1 answer
121 views
Can the x-axis labels be made as clickable ?

look in image that I attached.
Richard
Top achievements
Rank 1
 answered on 15 May 2012
2 answers
355 views
Hello,

I have following scenario.

On the Form I have RadButton with code:
protected void RadButton_tab_Click(object sender, EventArgs e)
        {
               sesja="abcdef";
               ScriptManager.RegisterStartupScript(Page, typeof(Page), "runTabelka", "openTabelka('"+sesja+"')", true);
        }
where openTabelka is javascript function located in body Form:
<telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
    <script type="text/javascript">
        function openTabelka(args) {
            var adres = "http://127.0.0.1/Tabela.aspx?" + args;
            window.open(adres, "_blank");
        }
    </script>
</telerik:RadScriptBlock>
next, I have script for key pressed on the Form:
function klik() {
            var k = event.keyCode;
            if (k == 13) {
                var button = $telerik.findButton("<%= RadButton_tab.ClientID %>");
                button.click();
            };
        }
and in body tag: <body onkeypress="javascript:klik()">

when I click (with mouse button) on my RadButton, function openTabelka is running and new page in Web Browser is opened.
but when I press Enter key, function klik() is fired, RadButton (RadButton_tab_Click) is fired (I see this in debugger),
line with ScriptManager.RegisterStartupScript(Page, typeof(Page), "runTabelka", "openTabelka('"+sesja+"')", true); is executed,
 but script openTabelka is not running.
where I make a mistake ?

regards, Dominik
Dominik
Top achievements
Rank 1
 answered on 15 May 2012
3 answers
165 views

<EditFormSettings InsertCaption="Assign/Modify Question" CaptionFormatString="Edit Record: {0}" 

 

 

CaptionDataField="QuestionId" EditFormType="Template">

 

 

<PopUpSettings Modal="True" Width="700px" Height="500px" />

 

 

<FormTemplate>

 

 

<asp:ValidationSummary ID="valSummaryApprove" ValidationGroup="ApproveGroup" ForeColor="DarkRed"

 BackColor="Transparent" runat="server" Width="550px" Font-Names="Verdana" Font-Size="8pt"

 TabIndex="-1" HeaderText="Validation Results" />

 

 

<asp:ValidationSummary ID="valSummaryReassign" ValidationGroup="ReassignGroup" ForeColor="DarkRed"

 BackColor="Transparent" runat="server" Width="550px" Font-Names="Verdana" Font-Size="8pt"

 TabIndex="-1" HeaderText="Validation Results" />

 

 

<asp:ValidationSummary ID="valSummary" ValidationGroup="UpdateGroup" ForeColor="DarkRed"

 BackColor="Transparent" runat="server" Width="550px" Font-Names="Verdana" Font-Size="8pt"

 TabIndex="-1" HeaderText="Validation Results" />



<table>
...

 <tr>

 <td>

 

<telerik:RadButton ID="RadButton1" ValidationGroup="ApproveGroup" TabIndex="14" CausesValidation="true" AutoPostBack="false"  Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Approve for Public Release" %>' runat="server" Skin="Web20"

 CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>

 </telerik:RadButton></td>

 

 

 <td>

 
<telerik:RadButton ID="RadButton2" ValidationGroup="ReassignGroup" TabIndex="15" CausesValidation="true" AutoPostBack="false" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Reassign" %>' runat="server" Skin="Web20"  

CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>

 </telerik:RadButton></td>

 

 

 <td>

 
<telerik:RadButton ID="Button1" ValidationGroup="UpdateGroup" TabIndex="16" CausesValidation="true"

Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' runat="server" Skin="Web20"

 CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>

</telerik:RadButton></td><td><telerik:RadButton ID="btnCancel" CommandName="Cancel" TabIndex="17" Text="Cancel" CausesValidation="False"

 runat="server" Skin="Web20"></telerik:RadButton></td>

 

 

 </tr>

</table>

 

Approve for Public Release and Reassign buttons do not fire itemcommand event unless I set autopostback to true, which loses my edits.

 

 

 

 

Please help.

Thanks in advance...
...
</table>

 

T
Top achievements
Rank 1
 answered on 15 May 2012
1 answer
421 views
Hi,

I am using radgrid for grouping datas. Currently there are two groups and i want all the groups to be collapsed by default. I have used the property GroupsDefaultExpanded but it is collapsing only the root groups. I confirmed this behaviour from the link below.  http://www.telerik.com/help/aspnet-ajax/grid-group-load-modes.html - in the caution section. I also checked that once the root item is expanded the child groups button click is also called and those items are also expanding. I need a solution to collapse the inner level groups on expanding the outer level groups. Is there a workaround for that. It would be very helpful if there is something.

Thank you.



Richard
Top achievements
Rank 1
 answered on 15 May 2012
1 answer
57 views
HI,
Sometimes in IE (8, 9) I can't resize my window using left or right border (trying to dragging).
But it's possible to do it using a corner of the window. After that the first way starts to work.

I'm using telerik 2010.1.415.20.
What's wrong?
Marin Bratanov
Telerik team
 answered on 15 May 2012
3 answers
111 views
Hi;
Is there any way to use an usercontrol for edititemteplate in radlistview like radgrid? 
Andrey
Telerik team
 answered on 15 May 2012
1 answer
523 views
Hi,
I am using 2 Radlistbox in my project for item transfer from source to destination list boxes and vice versa.
When user selecting item in soure listbox then automatically clear item selections in destination listbox.
i done it by using server side event OnSelectedIndexChanged of Radlistbox by adding RadlistboxSource.ClearSelection();
but how to do without OnSelectedIndexChanged event.

Please support.

Thanks.
Santhosh Naik

Richard
Top achievements
Rank 1
 answered on 15 May 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?