Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
266 views
Hello everyone,

I have a telerik Grid and when I try to use insert, update or delete the events on in the code behind never fire. The popup does go away though and it looks like the grid is being updated. This is what I have for the code:

<telerik:RadGrid
            ID="ClaimFormPartsGrid" runat="server"
            GridLines="None" Skin="Simple"
            AutoGenerateColumns="False"
            AllowSorting="False"
            AllowMultiRowSelection="False">
            <MasterTableView
                EditMode="PopUp" CommandItemDisplay="Top"
                InsertItemDisplay="Top" CommandItemSettings-ShowRefreshButton="False"
                CommandItemSettings-ShowAddNewRecordButton="True" AutoGenerateColumns="False" EnableViewState="True"
                DataKeyNames="key">
                <Columns>
                    <telerik:GridEditCommandColumn UniqueName="EditCommand"/>
                    <telerik:GridBoundColumn UniqueName="key" DataField="key" HeaderText="Name"/>
                    <telerik:GridBoundColumn UniqueName="value" DataField="value" HeaderText="Value"/>
                    <telerik:GridButtonColumn UniqueName="DeleteCommand" Text="Delete" CommandName="DeleteCommand" />
                </Columns>
                <EditFormSettings EditFormType="Template" InsertCaption="Adding new Claim Form Part"
                    CaptionFormatString="Editing Claim Form Part" PopUpSettings-Modal="True" PopUpSettings-ScrollBars="None">
                    <FormTemplate>
                        <div class="rust-form">
                            <fieldset class="no-bg">
                                <legend></legend>
                                <ul>
                                    <li>
                                        <asp:Label runat="server" ID="keyNameLabel" AssociatedControlID="KeyNameTextBox">Name: </asp:Label>
                                        <asp:TextBox runat="server" ID="keyNameTextBox"></asp:TextBox>
                                    </li>
                                    <li>
                                        <asp:Label runat="server" ID="keyValueLabel" AssociatedControlID="KeyValueTextBox">Value: </asp:Label>
                                        <asp:TextBox runat="server" ID="keyValueTextBox"></asp:TextBox>
                                    </li>
                                </ul>
                            </fieldset>
                            <ul class="rust-action-btns">
                                <li>
                                    <asp:Button ID="InsertUpdateButton" runat="server"
                                                Text="Save" CssClass="rust-primary-btn" TabIndex="1"
                                                CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "" %>' /> />
                                </li>
                                <li>
                                    <asp:Button ID="ClaimCancelButton" runat="server" CausesValidation="False"
                                                Text="Cancel" CssClass="rust-secondary-btn"
                                                CommandName="Cancel" />
                                </li>
                            </ul>
                        </div>
                    </FormTemplate>
                </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    this.ClaimFormPartsGrid.NeedDataSource += this.ClaimFormPartsGrid_NeedData;
    this.ClaimFormPartsGrid.ItemDataBound += this.ClaimFormPartsGrid_ItemDataBound;
    this.ClaimFormPartsGrid.InsertCommand += this.ClaimFormPartsGrid_InsertCommand;
    this.ClaimFormPartsGrid.UpdateCommand += this.ClaimFormPartsGrid_UpdateCommand;
    this.ClaimFormPartsGrid.DeleteCommand += this.ClaimFormPartsGrid_DeleteCommand;
}
 
protected void ClaimFormPartsGrid_NeedData(object sender, GridNeedDataSourceEventArgs e)
{
    var source = new List<KeyValuePair<string, string>>();
    source.Add(new KeyValuePair<string, string>("1", "1"));
    source.Add(new KeyValuePair<string, string>("2", "2"));
    source.Add(new KeyValuePair<string, string>("3", "3"));
    source.Add(new KeyValuePair<string, string>("4", "4"));
    this.ClaimFormPartsGrid.DataSource = source;
}
 
protected void ClaimFormPartsGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
    if(e.Item.IsInEditMode)
    {
        var gei = e.Item as GridEditableItem;
        if(gei == null)
        {
            return;
        }
 
        var nameTextbox = (TextBox)gei.FindControl("keyNameTextBox");
        var valueTextbox = (TextBox) gei.FindControl("keyValueTextBox");
 
        if(gei.OwnerTableView.IsItemInserted)
        {
            // Inserting.
            nameTextbox.Text = string.Empty;
            valueTextbox.Text = string.Empty;
        }
        else
        {
            // Editing.
            var keyValue= (KeyValuePair<string, string>) gei.DataItem;
            nameTextbox.Text = keyValue.Key.ToString();
            valueTextbox.Text = keyValue.Value.ToString();
        }
    }
    else
    {
        // displaying
        var gdi = e.Item as GridDataItem;
        if (gdi == null)
        {
            return;
        }
 
        var keyValue= (KeyValuePair<string,string>)gdi.DataItem;
 
 
        var deleteButton = gdi["DeleteCommand"].Controls[0] as LinkButton;
        if(deleteButton != null)
        {
            deleteButton.Attributes["onclick"] = "return confirm('Are you sure you want to delete " + keyValue.Key + "?')";
        }
    }
}
 
protected void ClaimFormPartsGrid_InsertCommand(object sender, GridCommandEventArgs e)
{
    var gei = e.Item as GridEditableItem;
    if (gei == null)
    {
        return;
    }
 
    var nameTextbox = (TextBox)gei.FindControl("keyNameTextBox");
    var valueTextbox = (TextBox)gei.FindControl("keyValueTextBox");
 
}
 
 
protected void ClaimFormPartsGrid_UpdateCommand(object sender, GridCommandEventArgs e)
{
    var gei = e.Item as GridEditableItem;
    if (gei == null)
    {
        return;
    }
 
    var oldName = (KeyValuePair<string, string>)gei.DataItem;
    var nameTextbox = (TextBox)gei.FindControl("keyNameTextBox");
    var valueTextbox = (TextBox)gei.FindControl("keyValueTextBox");
 
}
 
protected void ClaimFormPartsGrid_DeleteCommand(object sender, GridCommandEventArgs e)
{
    var gei = e.Item as GridEditableItem;
    if (gei == null)
    {
        return;
    }
 
}


Does anyone have an Idea?
Jayesh Goyani
Top achievements
Rank 2
 answered on 02 Mar 2012
3 answers
405 views
Hi,

I've searched the threads on this issue, and I've found that there does not seem to be a good, consistent global solution for really benefitting from the Autosize property.

Overall, it appears to me that if you page grows just a tiny bit after the PageLoad event, you get unsightly scroll bars.  The only way that I've been able to avoid that is to set the MinWidth/Height properties, which results in a somewhat time consuming "hit and miss" guessing game on the best sizes.  

It seems to me, that there should be a way to add a "Autosize" buffer, or something like, maybe utilizing a CSS.  Has anybody found a good way to tackle this globally, with CSS on the RadWindow, or the page itself, or by some other technique.  Or, does anyone know how to run the Autosize() function at a time later than the PageLoad, to help deal with the issue of the page grows a little but with some client side rendering or something?

Check out the screen shot for some perspective on my problem. 

Thanks a ton.  

Jim

Marin Bratanov
Telerik team
 answered on 02 Mar 2012
2 answers
115 views
Hi Telerik Team,

I need a DataTime control in which user can manually change mins as well   like dateedit of Dev express.

Please suggest me same.

Thanks in advance.      
Robin
Top achievements
Rank 1
 answered on 02 Mar 2012
1 answer
166 views
Trying to draw a vertical line with x-axis as Datetime. How to set the X-axis a Constant Date using MarkedZones.

<MarkedZones> 
                                                                <telerik:ChartMarkedZone Name="Marked zone 1" >
                                                                    <Appearance> 
                                                                        <Border Width="2" Color="Pink" /> 
                                                                    </Appearance> 
                                                                </telerik:ChartMarkedZone> 
                                                            </MarkedZones> 
Evgenia
Telerik team
 answered on 02 Mar 2012
1 answer
56 views
Hello,

I've just started experiencing this.  I have an Editor on a page.  I go to HTML view, paste in some HTML, which includes an image, then switch to DESIGN view, right click on the image, select Properties, and then for the Image Src, I browse to select a replacement image.  When I select it and click OK, it does NOT replace the value in the Image Src field.  To get this to work, I have to clear the Image Src value, then browse and select the image.

Any ideas?  Need more information?

Thank you.
Rumen
Telerik team
 answered on 02 Mar 2012
3 answers
84 views
I have some issues with ExportToPDF.

1. CheckBox(by GridCheckBoxColumn) is not displayed at PDF output.

2. When columns of grid is re-ordered, PDF is generated with the orginal column order not revised one.

If there is any suggestion, please let me know.

Thanks
Daniel
Telerik team
 answered on 02 Mar 2012
1 answer
96 views
When adding a new record how can we hide the filter in radgrid?
Shinu
Top achievements
Rank 2
 answered on 02 Mar 2012
8 answers
1.5K+ views
Whatever I do (and I've tried many ideas already given in these forums) i cannot get my columns to show currencies, just plain numeric values.

I want my grid to show the "buyprice" and totalcost columns as "{0:C}" or "{0:$###.##}"

Here's my code:

.aspx
<telerik:RadGrid  
        ID="RadGrid1" runat="server" 
        Width="95%" 
        OnNeedDataSource="RadGrid1_NeedDataSource" 
        > 
        <MasterTableView AutoGenerateColumns="false"
            <Columns> 
                <telerik:GridBoundColumn DataField="id" Visible="false" ReadOnly="true"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="symbol" HeaderText="Symbol"  ReadOnly="true" ></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="buyprice" HeaderText="Buy Price" DataType="System.Decimal" DataFormatString="{0:C}" ></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="totalcost" HeaderText="Total Cost" DataType="System.Decimal" DataFormatString="{0:C}" ></telerik:GridBoundColumn> 
                <telerik:GridButtonColumn  ConfirmText="Are you sure?" ConfirmDialogType="Classic" ButtonType="ImageButton" ImageUrl="/images/delete.gif"CommandName="Delete"> 
                </telerik:GridButtonColumn> 
            </Columns> 
        </MasterTableView> 
    </telerik:RadGrid> 

.aspx.cs
        protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
        { 
            string XMLFilePath = getXMLPath(); 
 
            DataSet ds = new DataSet(); 
            ds.ReadXml(XMLFilePath); 
 
            DataView dv = new DataView(ds.Tables[0]); 
            dv.Sort = "datecalculated DESC"
 
            RadGrid1.DataSource = dv
             
        } 

.xml
<?xml version="1.0" encoding="utf-8"?> 
<calculations> 
  <calculation id="1" symbol="SYM1" buyprice="3.4" totalcost="831.483" datecalculated="06/30/2010" /> 
  <calculation id="2" symbol="SYM2" buyprice="10.74" totalcost="1088" datecalculated="06/17/2010" /> 
</calculations> 

am I missing anything? Is my method of populating RadGrid1 causing this, can string formatting not be applied to boundcolumns? (I did try using GridNumericColumn, still without success).
Jr
Top achievements
Rank 1
 answered on 02 Mar 2012
3 answers
398 views
Hi,

check all checkboxes in radgrid on button click.  button is placed outside radgrid. I tried thos method on button click.

                CheckBox chb;
                for (int i = 0; i < RadGrid1.Items.Count; i++)
                {
                    chb = (CheckBox)RadGrid1.Items[i].FindControl("chkSelectItem");
                    chb.Checked = true;
                }
This will fix the check boxes in the radgrid on that page. if I move to another page(pagination), it will be unchecked in there.
Thanks in advance.
Pavlina
Telerik team
 answered on 02 Mar 2012
1 answer
118 views
Hello,

I have a Treeview called RadTreeView1 which is already populated as follows, this is working perfect:

Do While RS.Read
    If RS(0) = 1 Then
        Dim Node As New RadTreeNode
        Node.Text = (RS(2) & " " & RS(3) & " (" & RS(1) & ")")
        Node.Value = RS(1)
        Node.Checkable = True
        RadTreeView1.Nodes.Add(Node)
    Else
        Dim foundNode As RadTreeNode = RadTreeView1.FindNodeByValue(RS(5))
        If foundNode IsNot Nothing Then
            Dim Node As New RadTreeNode
            Node.Text = (RS(2) & " " & RS(3) & " (" & RS(1) & ")")
            Node.Value = RS(1)
            Node.Checkable = False
            foundNode.Nodes.Add(Node)
        End If
    End If


I've set the root values checkable=true and all the children as checkable=false (so the user can only check or uncheck the root values). Each node has a value which is an integer number.

What I need to do is to click on a button, and retrieve all those nodes that are checked. Im using the code below but its not working:

Imports Telerik.Web.UI
Partial Class Hierarchy_Compression
    Inherits System.Web.UI.Page
    Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        Dim Compression As IList(Of RadTreeNode) = RadTreeView1.CheckedNodes
        For Each node As RadTreeNode In Compression
            If node.Checked = True Then
                Response.Write(node.Value)
            End If
        Next
    End Sub
End Class

What am I doing wrong?!

Thanks.
Princy
Top achievements
Rank 2
 answered on 02 Mar 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?