Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
139 views
Hi,

I have a statically declared but dynamically created Grid.  The columns and their datatypes are not known until runtime.  So, I create regular GridBoundColumn at runtime.  Some columns are numeric and some columns need to be dropdowns, checkboxes etc.  I have all the code to create the boundcolumns and display it and edit it.  I guess I need to replace the auto-generated column editors in CreateColumnEditor event.  Is there a sample I can base my code upon?  Because the following code throws me an error "Object reference not set to an instance of an object".

Here is my code to create the columns.
    protected void DefineColumnsForGrid(RadGrid grid, DataTable tbl)  
    {  
        grid.Columns.Clear();  
        FormsIdentity user = (FormsIdentity)HttpContext.Current.User.Identity;  
        if (user == null)  
            return;  
        for (int i = 0; i < tbl.Columns.Count; i++)  
        {  
            GridBoundColumn col = new GridBoundColumn();  
            col.HeaderText = tbl.Columns[i].ColumnName;  
            col.DataField = tbl.Columns[i].ColumnName;  
            col.UniqueName = tbl.Columns[i].ColumnName;  
            col.DataType = tbl.Columns[i].DataType;  
            col.ReadOnly = true;    // isEditable  
            grid.Columns.Add(col);  
        }  
    }  
 


And here my code for CreateColumnEditor event:
    protected void rgForecast_CreateColumnEditor(object sender, GridCreateColumnEditorEventArgs e)  
    {  
        if (e.Column is GridBoundColumn)  
        {  
            if ((e.Column as GridBoundColumn).DataType == typeof(System.Decimal))  
            {  
                (e.Column as GridBoundColumn).ColumnEditorID = (e.Column as GridBoundColumn).UniqueName + "1";  
                e.ColumnEditor = new GridNumericColumnEditor(new GridNumericColumn());  
            }  
        }  
    }  
 

Please help.

Babu.
Babu Mannaravalappil
Top achievements
Rank 1
 answered on 16 Nov 2009
3 answers
478 views
Hi,
Im using the latest version of the prometheus controls. I've come across a problem where a radtextbox does not fire the textchanged event all the time.

I've managed to reproduce the problem on a simple page as follows:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadTextboxAutoPostbackBug.aspx.cs" Inherits="RadTextboxAutoPostbackBug" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"> 
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
        <asp:ScriptManager ID="ScriptManager1" runat="server"> 
        </asp:ScriptManager> 
    <div> 
        <telerik:radtextbox id="RadTextBox1" runat="server" autopostback="True" ontextchanged="RadTextBox1_TextChanged" 
            textmode="SingleLine" width="125px"></telerik:radtextbox> 
        <telerik:radtextbox id="RadTextBox2" runat="server" autopostback="True" ontextchanged="RadTextBox2_TextChanged"></telerik:radtextbox> 
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div> 
        <telerik:radajaxmanager id="RadAjaxManager1" runat="server" defaultloadingpanelid="RadAjaxLoadingPanel1"><AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="RadTextBox1"> 
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="Label1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="RadTextBox2"> 
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="Label1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
</AjaxSettings> 
</telerik:radajaxmanager> 
        <telerik:radajaxloadingpanel id="RadAjaxLoadingPanel1" runat="server" height="75px" 
            width="75px"> 
        <img src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' alt="Loading..." style="border:0px;" /> 
    </telerik:radajaxloadingpanel> 
    </form> 
</body> 
</html> 
 

The code behind:

using System; 
using System.Data; 
using System.Configuration; 
using System.Collections; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Web.UI.HtmlControls; 
 
public partial class RadTextboxAutoPostbackBug : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
 
    } 
    protected void RadTextBox1_TextChanged(object sender, EventArgs e) 
    { 
        Label1.Text = DateTime.Now.ToString() + ": TextBox1 Changed"; 
    } 
    protected void RadTextBox2_TextChanged(object sender, EventArgs e) 
    { 
        Label1.Text = DateTime.Now.ToString() + ": TextBox2 Changed"; 
    } 
} 

The autopostback will work the first time you change the text for both text boxes. The next time you try to change it, it will not fire, and it will also revert back to the old text that existed in the textbox.

Thanks,
Andrew Watt
Top achievements
Rank 1
 answered on 16 Nov 2009
1 answer
105 views
I have a Grid:

     <telerik:RadGrid ID="pracownicy" AllowSorting="true" runat="server" GridLines="None" 
         ShowFooter="true" DataMember="employee"> 
         <MasterTableView> 
             <RowIndicatorColumn> 
                 <HeaderStyle Width="20px"></HeaderStyle> 
             </RowIndicatorColumn> 
             <ExpandCollapseColumn> 
                 <HeaderStyle Width="20px"></HeaderStyle> 
             </ExpandCollapseColumn> 
             <Columns> 
                 <telerik:GridTemplateColumn HeaderText="Gracz" SortExpression="employee_name"> 
                     <ItemTemplate> 
                         <a href='<%# "http://www.erepublik.com/en/citizen/profile/" & Eval("employee_id") %>' 
                             target="_blank"> 
                             <%#Eval("employee_name")%></a> 
                     </ItemTemplate> 
                     <ItemStyle HorizontalAlign="Center" Width="200px" /> 
                     <HeaderStyle HorizontalAlign="Center" /> 
                 </telerik:GridTemplateColumn> 
                 <telerik:GridBoundColumn DataField="employee_skill" DataType="System.Double" HeaderText="UmiejÄ™tność" 
                     SortExpression="employee_skill" UniqueName="employee_skill"> 
                     <ItemStyle HorizontalAlign="Center" Width="100px" /> 
                     <HeaderStyle HorizontalAlign="Center" /> 
                 </telerik:GridBoundColumn> 
                 <telerik:GridBoundColumn DataField="employee_wellness" DataType="System.Double" HeaderText="Samopoczucie" 
                     SortExpression="employee_wellness" UniqueName="employee_wellness"> 
                     <ItemStyle HorizontalAlign="Center" Width="100px" /> 
                     <HeaderStyle HorizontalAlign="Center" /> 
                 </telerik:GridBoundColumn> 
                 <telerik:GridTemplateColumn DataField="employee_productivity" DataType="System.Double" 
                     HeaderText="Produktywność" SortExpression="employee_productivity" UniqueName="employee_productivity"> 
                     <ItemTemplate> 
                         <telerik:RadTextBox ID="productivity" Enabled="false" runat="server" Text='<%# Eval("employee_productivity") %>' 
                             Width="50px"> 
                             <DisabledStyle BorderColor="Transparent" ForeColor="Black" BackColor="Transparent" /> 
                         </telerik:RadTextBox></ItemTemplate> 
                     <ItemStyle HorizontalAlign="Center" Width="100px" /> 
                     <HeaderStyle HorizontalAlign="Center" /> 
                 </telerik:GridTemplateColumn> 
                 <telerik:GridTemplateColumn HeaderText="Pensja" UniqueName="salary"> 
                     <ItemTemplate> 
                         <telerik:RadNumericTextBox ID="salary" runat="server" NumberFormat-DecimalDigits="2" 
                             NumberFormat-GroupSeparator="" NumberFormat-DecimalSeparator="," Width="75px" 
                             Type="Currency" ShowSpinButtons="true" Text='<%# Eval("employee_salary") %>'> 
                             <ClientEvents OnKeyPress="recalculate" OnValueChanged="recalculate" /> 
                             <IncrementSettings Step="0.05" InterceptMouseWheel="true" /> 
                         </telerik:RadNumericTextBox> 
                     </ItemTemplate> 
                     <ItemStyle HorizontalAlign="Center" Width="100px" /> 
                     <HeaderStyle HorizontalAlign="Center" /> 
                 </telerik:GridTemplateColumn> 
                 <telerik:GridTemplateColumn HeaderText="Profit" UniqueName="profit"> 
                     <ItemTemplate> 
                         <telerik:RadTextBox ID="profit" runat="server" Width="50px"> 
                         </telerik:RadTextBox></ItemTemplate> 
                     <ItemStyle HorizontalAlign="Center" Width="100px" /> 
                     <HeaderStyle HorizontalAlign="Center" /> 
                     <FooterTemplate> 
                         <telerik:RadTextBox ID="total" Enabled="false" runat="server" Width="50px"> 
                             <DisabledStyle BorderColor="Transparent" ForeColor="Black" BackColor="Transparent" /> 
                         </telerik:RadTextBox> 
                     </FooterTemplate> 
                 </telerik:GridTemplateColumn> 
             </Columns> 
         </MasterTableView> 
     </telerik:RadGrid> 

The grid is in non-edit mode. I have NumericTextBoxes in normal, default view.

I enabled sorting through few columns.

The problem is that when I enter some value in NumericTextBox and press sort, the data is sorting ok, but I losing the value inserted before sorting.

How to prevent it?
Veli
Telerik team
 answered on 16 Nov 2009
1 answer
68 views
I am developing an extensive web application with many datagrids and am wanting to use the popup editor to make coding simpler.

But I need to do some extra data validation and manipulation on server-side. Is it possible to access the inputs from the modal pop up editor on the radgrid insert_command event?

This is how I build my grid asp-side:

<telerik:RadGrid ID="gvFTE2009" runat="server" Width="550px"> 
   <MasterTableView EditMode="PopUp" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add another category" 
                                                             ShowHeadersWhenNoRecords="true" ShowHeader="false" NoMasterRecordsText="No Other Categories exist. Click 'Add another category' to add a new category"> 
      <EditFormSettings InsertCaption="Add another category" CaptionDataField="" PopUpSettings-Modal="true"/> 
      <Columns>                                                    
         <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="columnDelete" ItemStyle-Width="55px"> 
         </telerik:GridButtonColumn> 
      </Columns>                                                                                           
   </MasterTableView> 
</telerik:RadGrid> 


And this is how I want to bind my table server-side:           
sqlString = "Select .... " 
ds = SqlHelper.ExecuteDataset(Conn, Data.CommandType.Text, sqlString, sqlparam) 
If ds.Tables(0).Rows.Count > 0 Then 
   gvFTE2009.DataSource = ds.Tables(0) 
   gvFTE2009.DataBind() 
End If 


Drew
Top achievements
Rank 2
 answered on 16 Nov 2009
1 answer
70 views
Is there a way I can EnableKeyboardShortcuts but not allow InitInsertKey?
I want users to be able to do all the short cuts but insert.


Tsvetoslav
Telerik team
 answered on 16 Nov 2009
1 answer
91 views

Hi,

Is it possible to set up self-referencing hierarchy when using client-side data-binding?

I've successfully created such grid with 'regular' server side data-bindings but when i switch client-side ones (declarative or non-declarative) it remains flat.

Greetings,

Tom

Nikolay Rusev
Telerik team
 answered on 16 Nov 2009
3 answers
86 views
Hello,

RadGrid is a good tool ...but could be improved.

I discovered the finally integrated buttons to export to Excel, Word,pdf,csv...perfect.
But I am still disapointed we still have to add manually javascript to the page:
<script type="text/javascript">  
            function onRequestStart(sender, args)  
            {  
                if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 ||  
                    args.get_eventTarget().indexOf("ExportToWordButton") >= 0 ||  
                    args.get_eventTarget().indexOf("ExportToPdfButton") >= 0 ||  
                    args.get_eventTarget().indexOf("ExportToCsvButton") >= 0)  
                {  
 
                    args.set_enableAjax(false);  
                }  
            }  
        </script> 
 

This should be done by control !

And we should have a way to add from codebehind several javascript functions which would be called OnRequestStart.


Thanks Telerik for this tool but thanks doing some more efforts.

CS



Daniel
Telerik team
 answered on 16 Nov 2009
3 answers
87 views
 I attached the image file where you can see what happens when scrolls are appearing within opened Page Size on client machine. I tried to reproduce it on development environment and couldn't. Can you give me any tips how to solve it (or reproduce).
Pavlina
Telerik team
 answered on 16 Nov 2009
1 answer
246 views
Hello,
I'm having some issues trying to use the Popup Edit Form in a RadGrid that is located inside a DIV with the overflow set to hidden.  When Insert/Edit is clicked in the RadGrid the PopupEdit form is displayed, but it is cut off due to the DIV overflow requirement (due to the rest of the layout, the div needs to retain the overflow: hidden).

Is there a way to get the Popup Edit form to show without the window contents being cut off despite the container div having a overflow setting of hidden, other that re-positioning the Popup so it does not appear near the edges (if this is the only way, then is it possible to not allow the user to move the Popup)?

        RadGrid1.MasterTableView.EditMode = GridEditMode.PopUp 
        RadGrid1.MasterTableView.EditFormSettings.PopUpSettings.Modal = True 

/* column container */ 
.containerinmulticolumn { 
    position:relative;   
    clear:both; 
    float:left; 
    width:100%;         /* width of whole page */ 
    overflow:hidden;        /* This chops off any overhanging divs...some some CSS left out of post */ 
} 


Dimo
Telerik team
 answered on 16 Nov 2009
2 answers
172 views
Hi,
      I want to resize the RadGrid on the client side on window resize. Right now, i can do that. The issue is that the whole mastertable got resized as i set the height to be 100%. 
      I want the master table to be 100% but i do not want the rows to be resized (stretch). I want fix size for the rows. So, if there is no data i want empty grid with 100 % height and the pager right at the bottom. Similarly, for less records, show few records and then all empty space and then right at the bottom, show the pager.
       Right now , it strectches all the records height to fill the space. It does resize though which is great.
      Also, i have custom paging on, so i only fetch data page by page. The virtual count is also set programmatically. now, how can i achieve the functionality ?

Regards,

Osman
Senior Developer
Dimo
Telerik team
 answered on 16 Nov 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?