Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
483 views
Hi,
 
I am new to .Net programming and trying to impliment RadPivotGrid to develop a report.
 
There is no issue with RadPivotGrid implimentation. But, having difficulties in accessing Row and Column Group values.
 
As shown in Code behind, I am looking for corresponding sic_2_code and effective_year value for selected data cell.
 
<Fields>
                <telerik:PivotGridRowField DataField="sic_2_code" Caption="SIC Group" ZoneIndex="0">
                </telerik:PivotGridRowField>
                <telerik:PivotGridColumnField DataField="effective_year" Caption="Year" ShowGroupsWhenNoData="false">
                </telerik:PivotGridColumnField>
                <telerik:PivotGridAggregateField DataField="Proposed Premium" DataFormatString="{0:$#,##0}">
                    <CellTemplate>
                        <asp:LinkButton ID="LB_ProposedPremium" runat="server" OnClick="LB_ProposedPremium_Click">
            <%# string.Format("{0:$#,##0}", Container.DataItem)%>
                        </asp:LinkButton>
                    </CellTemplate>
                </telerik:PivotGridAggregateField>
</Fields>
 
Code Behind

protected void LB_ProposedPremium_Click(Object sender, EventArgs e)
    {
       
        string sBusinessSegment = string.Join(",", RCB_BusinessSegment.CheckedItems.Select(x => x.Value).ToArray());
     
//I need values of sic_2_code and effective_year to pass to another page
 
string sSICCode =??
string sEffectiveYear =??
 
 
        StringBuilder sb = new StringBuilder();
        sb.Append("NB_YearToYearSales.aspx");
        sb.Append("?SegmentID=" + sBusinessSegment);
sb.Append("&SICCode=" + sSICCode);
sb.Append("&EffectiveYear =" + sEffectiveYear);
        Response.Redirect(sb.ToString());
    }
Radoslav
Telerik team
 answered on 18 Aug 2014
2 answers
86 views
First of all, some things are working correctly.  See the attached screenshot.  You'll note that there is no option to insert and no option to delete.  Also if you go to edit 2 of the three columns are blanked out.   And importantly, the grid is working with our master page which took substantial modification of the automatically created grid's aspx markup (not referring to the code behind) and by automatic grid I mean the one that is created by right clicking in visual studio and choosing a RadGrid with CRUD.

I have also included the aspx file and code behind.  If you look in the code behind it includes the class from the code from the CRUD example on the telerik website (http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/automatic-crud-operations/defaultcs.aspx).  The reason a line is commented out is because uncommenting it  produced a 'does not exist in current context error' regarding radgrid 1.

The other (partial) codebehind class is inherited from another developer who made a similar form in a different part of the application in case it helps.

The question I have is what needs to be done to make the grid save?   Do I have to change an option?  Do I have to modify the C# code?   The more specific the answer, the better.  The answers in my last thread definitely worked.

Here's what happens now.  You hit the save button and the values automatically go back to what they were, without changing.


----- aspx file
<%@ Page Language="C#" MasterPageFile="~/MasterPages/Main.Master"  AutoEventWireup="true"  CodeBehind="GlobalSettings.aspx.cs" Inherits="RadGridAutomaticCrudOperations" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphCenter" runat="server">
    <telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
        <script type="text/javascript">

            function OnClientClose(sender, eventArgs) {


                if (eventArgs.get_argument() == 'true')
                    $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("Reload");

                else
                    return;
            }

        </script>
        </telerik:RadCodeBlock>
<telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True" AllowSorting="False"
            AllowAutomaticInserts="True" PageSize="10" AllowAutomaticUpdates="True" AllowMultiRowEdit="False"
            AllowPaging="False" DataSourceID="DataSource1" OnItemUpdated="RadGrid1_ItemUpdated"
            AllowFilteringByColumn="False" Skin ="Windows7" OnItemDeleted="RadGrid1_ItemDeleted" OnNeedDataSource="RadGrid1_NeedDataSource" >
            <PagerStyle Mode="NextPrevAndNumeric" />
            <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames=""
                DataSourceID="DataSource1" HorizontalAlign="NotSet" EditMode="InPlace" AutoGenerateColumns="False">
                <CommandItemSettings ExportToPdfText="Export to PDF" ShowAddNewRecordButton="false" />
                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
                </RowIndicatorColumn>
                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>               
                    <telerik:GridBoundColumn DataField="Description" FilterControlAltText="Filter Description column" HeaderText="Description" SortExpression="Description" UniqueName="Description" ReadOnly="true">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Value" FilterControlAltText="Filter Value column" HeaderText="Value" SortExpression="Value" UniqueName="Value">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn DataField="IsActive" DataType="System.Boolean" FilterControlAltText="Filter IsActive column" HeaderText="IsActive" SortExpression="IsActive" UniqueName="IsActive" ReadOnly="true">
                    </telerik:GridCheckBoxColumn>
 
                </Columns>
                <EditFormSettings>
                   <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                    <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                    <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
                        Width="100%" />
                    <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                    <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                    <EditColumn ButtonType="ImageButton"
                        UniqueName="EditCommandColumn1" CancelText="Cancel edit">
                    </EditColumn>
                    <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                </EditFormSettings>
            </MasterTableView>
            <FilterMenu EnableImageSprites="True">
            </FilterMenu>
        </telerik:RadGrid>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
    </telerik:radajaxpanel>
        <asp:sqldatasource selectcommand="SELECT Description, Value, IsActive FROM AppConfiguration" connectionstring="<%$ ConnectionStrings:SludgeBillingSystem %>" providername="System.Data.SqlClient" id="DataSource1" runat="server"></asp:sqldatasource>
            </asp:Content>

----- code behind
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;

/// <summary>
/// Summary description for defaultcs
/// </summary>
public class defaultcs : System.Web.UI.Page
{
    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            if (!(e.Item is GridEditFormInsertItem))
            {
                GridEditableItem item = e.Item as GridEditableItem;
                GridEditManager manager = item.EditManager;
                GridTextBoxColumnEditor editor = manager.GetColumnEditor("CustomerID") as GridTextBoxColumnEditor;
                editor.TextBoxControl.Enabled = false;
            }
        }
    }
    protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e)
    {
        if (e.Exception != null)
        {

            e.ExceptionHandled = true;
            SetMessage("Customer cannot be inserted. Reason: " + e.Exception.Message);

        }
        else
        {
            SetMessage("New customer is inserted!");
        }
    }
    private void DisplayMessage(string text)
    {
    //  RadGrid1.Controls.Add(new LiteralControl(string.Format("<span style='color:red'>{0}</span>", text)));
    }
    
    private void SetMessage(string message)
    {
        gridMessage = message;
    }

    private string gridMessage = null;

    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(gridMessage))
        {
            DisplayMessage(gridMessage);
        }
    }
}

public partial class RadGridAutomaticCrudOperations : System.Web.UI.Page
{
    private string gridMessage = null;

    protected void RadGrid1_DataBound(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(gridMessage))
        {
            DisplayMessage(gridMessage);
        }
    }

    protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)
    {
        if (e.Exception != null)
        {
            e.KeepInEditMode = true;
            e.ExceptionHandled = true;
            SetMessage("Update failed. Reason: " + e.Exception.Message);
        }
        else
        {
            SetMessage("Item updated!");
        }
    }

    protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e)
    {
        if (e.Exception != null)
        {
            e.ExceptionHandled = true;
            SetMessage("Insert failed! Reason: " + e.Exception.Message);
        }
        else
        {
            SetMessage("New product is inserted!");
        }
    }

    protected void RadGrid1_ItemDeleted(object source, GridDeletedEventArgs e)
    {
        if (e.Exception != null)
        {
            e.ExceptionHandled = true;
            SetMessage("Delete failed! Reason: " + e.Exception.Message);
        }
        else
        {
            SetMessage("Item deleted!");
        }
    }

    private void DisplayMessage(string text)
    {
        RadGrid1.Controls.Add(new LiteralControl(string.Format("<span style='color:red'>{0}</span>", text)));
    }

    private void SetMessage(string message)
    {
        gridMessage = message;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        //    RadGrid.

    }

    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {

    }
}
Princy
Top achievements
Rank 2
 answered on 18 Aug 2014
1 answer
67 views
can anyone suggest a way of persisting the visiblilty of a node after postback.

I am using javascript to node.set_visible(false) and using a tree.trackChanges() and tree.commitChanges() around my code...

All other settings such as enabled/disabled and css styles are honoured on each node... but this setting does not seem to be... am I missing something?
Shinu
Top achievements
Rank 2
 answered on 18 Aug 2014
7 answers
182 views
1. I have RadGrid
2. I have DetailTable 
3. All master rows have detail rows
4. All rows expanded

Why get_nestedViews()[0] have value only for first row in master grid?!

                var grid = $find("<%=masterGrid.ClientID %>");
                 var rows = grid.get_masterTableView().get_dataItems();

                    for (var i = 0; i < rows.length; i++) {
                        if (rows[i].get_nestedViews().length > 0)
                        {
                            var nestedView = rows[i].get_nestedViews()[0];
                            .......
                        }                        
Princy
Top achievements
Rank 2
 answered on 18 Aug 2014
3 answers
118 views
Dear Team,

I have a rad Grid, with in which I have created a  checkbox column and assing the Data to this grid. The check box is getting check or unchecked according to the Data. Perferct till here.

<telerik:GridTemplateColumn HeaderText="IsIndividual" UniqueName="IsIndividual" ReadOnly="true">
<ItemTemplate>
<asp:CheckBox ID="chkboxIsIndividual" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>

But this check box appears editable, I can uncheck/ check it in the Grid. But I want this column to be read Only. The grid should show checked/unchecked as per the data but should not allow to edit this checkbox. When I try to make the enable property to false, all the records a show checked, which is incorrect :(


Below is the code in the
radCBTransactionDetails_ItemCreated to check/uncheck the checkbox.

if (column.UniqueName == "IsIndividual" && column is GridTemplateColumn)
{
CheckBox chk = (CheckBox)e.Item.FindControl("chkboxIsIndividual");
// chk.Enabled = false;
if (gridItem.OwnerTableView.DataKeyValues[gridItem.ItemIndex]["IsIndividual"].ToString().ToUpper().Equals("TRUE"))
{
chk.Checked = true;
//chk.Enabled = false;
editLink.Text = "ViewIndividual";
}
else if (gridItem.OwnerTableView.DataKeyValues[gridItem.ItemIndex]["IsIndividual"].ToString().ToUpper().Equals("FALSE"))
{
chk.Checked = false;
//chk.Enabled = true;
editLink.Text = "Bulk";

}
}​

Please help me with this asap.
Shinu
Top achievements
Rank 2
 answered on 18 Aug 2014
3 answers
104 views
1,SingleClick="True"
2,we have some validator at codebehind

when throw new exception("XXXX"), the button is disabled.

how can i make it enabled?
wk
Top achievements
Rank 1
 answered on 18 Aug 2014
3 answers
85 views
i am using telerik Version=2011.3.1115.35 . i want to use singleclick functionality. my code is in asp.net VB, its urgent please help
SANJAY
Top achievements
Rank 1
 answered on 16 Aug 2014
6 answers
192 views
I want to have some javascript code on OnClientReordering. It works fine however code also fires on load or databind of the RadListBox.
Please help!
David
Top achievements
Rank 1
Iron
Iron
Veteran
 answered on 15 Aug 2014
2 answers
312 views
Hello,

I have a RadEditor that is supposed to use the Image Manager that allows them to upload and insert pictures. Here is my code for formatting it from the C# side. The imgPath created is a virtual path.

string imgPath = GenerateOutputDirectory(false);
CreateDirectoryIfNotExist(imgPath);
RadEditor1.ImageManager.ViewPaths = new string [] {imgPath};
RadEditor1.ImageManager.UploadPaths = new string[] { imgPath };
RadEditor1.ImageManager.EnableAsyncUpload = true;
RadEditor1.ImageManager.SearchPatterns = new string[] { "*.jpeg", "*.jpg", "*.bmp", "*.gif", "*.png" };


I create a string that creates the virtual path in imgPath, then if the directory does not exist, I create it so the imgPath exists for sure. Then I attempt to set the View and Upload path of the image manager to have those folders. However, when I open the image manager, this is what I see: (attached .png image)

The way it looks it seems that my paths are not being set. Why is this? The imgPath is the correct virtualPath. 

  
Jason
Top achievements
Rank 1
 answered on 15 Aug 2014
2 answers
116 views
my raddropdowntree appears always at the top of html DOM , before the form , with absolute position

How can keep it in the same place I put in the aspx page with absolute positioning .

Magdalena
Telerik team
 answered on 15 Aug 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?