Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
422 views
Folks,

I am using VS2010 with RadControls for ASP.NET AJAX Q2 2012 SP1. I would like to hide certain ComboBox items based on Values from an array. Below is my complete code. Any help will be appreciated.
Thanks
gc_0620
________________
<telerik:RadComboBox ID="Address_LocationRadComboBox" runat="server" SelectedValue='<%# Bind("Address_Location") %>'
    Text='<%# Bind("Address_Location") %>' Width="150px">
    <Items>
        <telerik:RadComboBoxItem runat="server" Text="Florida" Value="Florida" />
        <telerik:RadComboBoxItem runat="server" Text="New Jersey" Value="New Jersey" />
        <telerik:RadComboBoxItem runat="server" Text="New York" Value="New York" />
        <telerik:RadComboBoxItem runat="server" Text="Ohio" Value="Ohio" />
        <telerik:RadComboBoxItem runat="server" Text="Wisconsin" Value="Wisconsin" />
    </Items>
</telerik:RadComboBox>
 
.........
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  string[] retrievedLocations = (string[])Session["LocationData"];
  Array.Sort(retrievedLocations);
 
  // Assuming Array retrievedLocations has following Values:
 
  // New Jersey
  // New York
  // Wisconsin
 
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
 
    {
        GridEditableItem item = (GridEditableItem)e.Item;
 
        // Beginning of Loop each row in array retrievedLocations until no rows in array
 
        RadComboBox combo = (RadComboBox)item.FindControl("Address_LocationRadComboBox");
 
        foreach (RadComboBoxItem ComboItem in combo.Items)
        {
            if (ComboItem.Value != row value of array retrievedLocations)
            {
               ComboItem.Visible = false;
            }
            else
            {
               ComboItem.Visible = true;
            }
 
        }
        
       // End of Loop each row in array retrievedLocations until no rows in array
 
    }
}


gc_0620
Top achievements
Rank 1
 answered on 14 Sep 2012
6 answers
1.1K+ views
I have a need to show a grid will several columns that I don't want the user to see when the grid goes into edit mode.
I am adding the source code to the grid. I need to hide the "Date Due", "Description", "User Reference", etc...
                                <telerik:RadAjaxPanel ID="apnlPayments" runat="server" LoadingPanelID="ajaxLoadingPanel">
                            <telerik:RadGrid ID="gridPayments" runat="server"  AllowAutomaticDeletes="true" AllowAutomaticUpdates="true"
                                AllowAutomaticInserts="true" AllowFilteringByColumn="false" AllowPaging="false" 
                                AllowSorting="true" AllowMultiRowSelection="true" CellSpacing="0" CellPadding="0"
                                PageSize="500" ShowGroupPanel="false" AllowCustomPaging="false" 
                                EnableLinqExpressions="false" GridLines="Both" HeaderStyle-Wrap="false"
                                AutoGenerateColumns="false" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px"
                                OnItemDataBound="grid_ItemDataBound" OnPageIndexChanged="grid_PageIndexChanged"
                                OnPageSizeChanged="grid_PageSizeChanged" OnNeedDataSource="grid_NeedDataSource"
                                OnInsertCommand="gridPayments_InsertCommmand" OnUpdateCommand="gridPayments_UpdateCommand"
                                OnDeleteCommand="gridPayments_DeleteCommand" OnPreRender="gridPayments_PreRender">
                                <ClientSettings allowautoscrollondragdrop="false" allowexpandcollapse="false" allowgroupexpandcollapse="false">
                                    <Selecting AllowRowSelect="true" UseClientSelectColumnOnly="true" />
                                    <Scrolling AllowScroll="false" UseStaticHeaders="true"  FrozenColumnsCount="4" />
                                    <ClientEvents OnGridCreated="grid_GridCreated" />
                                    <Resizing AllowResizeToFit="true" EnableRealTimeResize="true" />
                                </ClientSettings>
                                <MasterTableView EditMode="EditForms" CommandItemDisplay="Top" AutoGenerateColumns="false"
                                    DataKeyNames="LoanPaymentID" InsertItemPageIndexAction="ShowItemOnCurrentPage">
                                    <ItemStyle CssClass="Row0" />
                                    <AlternatingItemStyle CssClass="Row1" />
                                    <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"><HeaderStyle Width="20px" /></RowIndicatorColumn>
                                    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"><HeaderStyle Width="20px" /></ExpandCollapseColumn>
                                    <Columns>
                                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" Visible="true">
                                            <ItemStyle HorizontalAlign="Center" Wrap="false" VerticalAlign="Middle" /></telerik:GridEditCommandColumn>
                                            <telerik:GridButtonColumn ConfirmText="Delete this Payment?" ConfirmDialogType="RadWindow"
                                            ConfirmTitle="Delete" ButtonType="ImageButton" ImageUrl="~/Images/icon_delete.png"
                                            CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                                            <ItemStyle HorizontalAlign="Center" />
                                        </telerik:GridButtonColumn>
                                        <telerik:GridBoundColumn DataField="LoanPaymentPS_ACCT_NO" MaxLength="50" FilterControlAltText="Filter LoanPaymentPS_ACCT_NO column"
                                            HeaderStyle-Wrap="false" HeaderText="PS ACCT NO" SortExpression="LoanPaymentPS_ACCT_NO"
                                            UniqueName="PS_ACCT_NO" ReadOnly="true">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridDateTimeColumn DataField="LoanPaymentDateDue" DataFormatString="{0:MM/dd/yyyy}"
                                            FilterControlAltText="Filter LoanPaymentDateDue column" HeaderStyle-Wrap="false"
                                            HeaderText="DATE DUE" SortExpression="LoanPaymentDateDue" UniqueName="LoanPaymentDateDue" ReadOnly="true">
                                        </telerik:GridDateTimeColumn>
                                        <telerik:GridDateTimeColumn DataField="LoanPaymentDatePaid" DataFormatString="{0:MM/dd/yyyy}"
                                            FilterControlAltText="Filter LoanPaymentDatePaid column" HeaderStyle-Wrap="false"
                                            HeaderText="DATE PAID" SortExpression="LoanPaymentDatePaid" UniqueName="LoanPaymentDatePaid" DataType="System.DateTime">
                                        </telerik:GridDateTimeColumn>
                                        <telerik:GridNumericColumn DataField="LoanPaymentAmount" NumericType="Currency" FilterControlAltText="Filter LoanPaymentAmount column"
                                            HeaderStyle-Wrap="false" HeaderText="AMOUNT" SortExpression="LoanPaymentAmount"
                                            UniqueName="LoanPaymentAmount">
                                        </telerik:GridNumericColumn>
                                        <telerik:GridBoundColumn DataField="LoanPaymentDescription" MaxLength="50" FilterControlAltText="Filter LoanPaymentDescription column"
                                            HeaderStyle-Wrap="false" HeaderText="DESCRIPTION" SortExpression="LoanPaymentDescription"
                                            UniqueName="LoanPaymentDescription">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="LoanPaymentUserReference" MaxLength="50" FilterControlAltText="Filter LoanPaymentUserReference column"
                                            HeaderStyle-Wrap="false" HeaderText="USER REFERENCE" SortExpression="LoanPaymentUserReference"
                                            UniqueName="LoanPaymentUserReference">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="LoanPaymentMethodNo" MaxLength="50" FilterControlAltText="Filter LoanPaymentMethodNo column"
                                            HeaderStyle-Wrap="false" HeaderText="METHOD NO" SortExpression="LoanPaymentMethodNo"
                                            UniqueName="LoanPaymentMethodNo">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="LoanPaymentMethodReference" MaxLength="50" FilterControlAltText="Filter LoanPaymentMethodReference column"
                                            HeaderStyle-Wrap="false" HeaderText="METHOD REFERENCE" SortExpression="LoanPaymentMethodReference"
                                            UniqueName="LoanPaymentMethodReference">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="LoanPaymentType" MaxLength="50" FilterControlAltText="Filter LoanPaymentType column"
                                            HeaderStyle-Wrap="false" HeaderText="TYPE" SortExpression="LoanPaymentType" UniqueName="LoanPaymentType">
                                        </telerik:GridBoundColumn>
                                    </Columns>
                                </MasterTableView>
                                <FilterMenu EnableImageSprites="false" />
                                <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default" />
                            </telerik:RadGrid>                   
                        </telerik:RadAjaxPanel>
Pam
Top achievements
Rank 2
 answered on 14 Sep 2012
1 answer
145 views
Hello, 

        I have a dataset which is attached "Db Results.png" as below.
        Based on the DB results, I'm able to pull the data into screen as "Grid Results as per the DB column names.png".

        But my requirement is, If the user generate a report on Monday 09/17/2012, then he has to see the data for next five days with respective of specified dates.

       If you see the image "Expected Final Grid Results Should looks as like this.png", in that grid, the results are with respective of each date. Please could you help my how I can Acheive it?

Please find the below code:

Code.ASPX:

<

 

 

div id="dvResult" style="min-width: 64%; width: 64%; height: 98%; float: right;">

 

<fieldset>

 

<legend>Result</legend>

 

<asp:UpdatePanel ID="updReportData" runat="server">

 

<ContentTemplate>

 

<asp:Label ID="lblMetricsInfo" runat="server"></asp:Label></Br>

 

<asp:Label ID="lblMetricsBusinessInfo" runat="server"></asp:Label>

 

<div style="text-align: right">

 

<asp:LinkButton ID="lnkShowAll" Text="Show All" ToolTip="Toggle grid paging" runat="server"

 

CommandName="CurrentGrid" CommandArgument="ReportData"></asp:LinkButton>

 

<asp:ImageButton ID="imgToExcel" runat="server" ImageUrl="../images/excel_16x16.png"

 

AlternateText="Export data to Excel" ToolTip="Export grid data to Excel." Style="width: 16px;

 

 

height: 16px; cursor: pointer;" CommandName="CurrentGrid" CommandArgument="ReportData" />

 

</div>

 

<div class="gridWrapper">

 

<telerik:RadGrid ID="grdReportData" runat="server" PageSize="20" AllowSorting="True"

 

AllowPaging="True" AutoGenerateColumns="True" ShowGroupPanel="True" CssClass="grid"

 

ClientSettings-Resizing-AllowColumnResize="true" ClientSettings-Resizing-ResizeGridOnColumnResize="true"

 

ShowFooter="true">

 

<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>

 

<GroupPanel Text="">

 

</GroupPanel>

 

<MasterTableView Width="100%" TableLayout="Fixed">

 

<NoRecordsTemplate>

No records exist for the given criteria.

 

</NoRecordsTemplate>

 

</MasterTableView>

 

<ClientSettings AllowGroupExpandCollapse="True" AllowDragToGroup="True">

 

<Resizing AllowColumnResize="True" ResizeGridOnColumnResize="True"></Resizing>

 

</ClientSettings>

 

</telerik:RadGrid>

 

</div>

 

</ContentTemplate>

 

<Triggers>

 

<asp:PostBackTrigger ControlID="imgToExcel" />

 

</Triggers>

 

</asp:UpdatePanel>

 

</fieldset>

 

</div>


Code.ASPX.vb File

Public sub LoadReport()
Dim Ds as dataset = nothing
Ds = Obj.GetDate()

grdReportData.DataSource = ds

grdReportData.DataBind()
End Sub

 

 

Thank You In Advance,
Satish.

Satish
Top achievements
Rank 1
 answered on 14 Sep 2012
5 answers
131 views
Hi,

   I would like to log the source file and path being copied to the destination directory. When using the OnClientCopy I do get a value for the RadFileExplorerEventArgs get_newPath() but not for the get_item. Is there a way to get this value?

Thanks!

Jed
Jed
Top achievements
Rank 1
 answered on 14 Sep 2012
4 answers
215 views
I have a radgrid that displays a date from a record in a database along with the other information in that record.  What I want to do is automatically populate that date with the current date when a user enters a new row - AND I want that date to show up on the screen before they insert it.  I know how to populate the column at the time of insert, but what I would like is when a user presses "Add new record" that a Label shows in the Edit form with the current date.

Here is my code:

 

 

 <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"   
        DataSourceID="LogBookODS" GridLines="None" AllowFilteringByColumn="True"   
        AllowPaging="True" AllowSorting="True" AllowAutomaticDeletes="True"   
        AllowAutomaticInserts="True" AllowAutomaticUpdates="True"   
        Skin="Office2007">  
<MasterTableView DataKeyNames="LogBookID" DataSourceID="LogBookODS"   
            CommandItemDisplay="Top">  
<RowIndicatorColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</RowIndicatorColumn> 
 
<ExpandCollapseColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</ExpandCollapseColumn> 
    <Columns> 
        <telerik:GridBoundColumn DataField="LogBookID" DataType="System.Int32"   
            HeaderText="LogBookID" ReadOnly="True" SortExpression="LogBookID"   
            UniqueName="LogBookID" Visible="False">  
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="PatientID" DataType="System.Int32"   
            HeaderText="PatientID" SortExpression="PatientID" UniqueName="PatientID"   
            Visible="False" ReadOnly="True">  
        </telerik:GridBoundColumn> 
        <telerik:GridTemplateColumn DataField="LogEntryDate" DataType="System.DateTime"   
            HeaderText="Entry Date" SortExpression="LogEntryDate"   
            UniqueName="LogEntryDate">  
            <EditItemTemplate> 
            <asp:Label ID="CurrDateLbl" runat="server"></asp:Label> 
            <asp:TextBox ID="CurrDateTxtBx" runat="server" Visible="false" Text='<%# Bind("LogEntryDate") %>'></asp:TextBox> 
            </EditItemTemplate> 
            <ItemTemplate> 
                <asp:Label ID="LogEntryDateLabel" runat="server"   
                    Text='<%# Eval("LogEntryDate","{0:d}") %>'></asp:Label> 
            </ItemTemplate> 
        </telerik:GridTemplateColumn> 
          
        <telerik:GridBoundColumn DataField="LogDescription" HeaderText="Description "   
            MaxLength="100" UniqueName="LogDescription">  
        </telerik:GridBoundColumn> 
          
        <telerik:GridTemplateColumn DataField="LogEntry" HeaderText="Log Entry"   
            SortExpression="LogEntry" UniqueName="LogEntry" AllowFiltering="False">  
            <EditItemTemplate> 
                <br /> 
                <telerik:RadEditor ID="RadEditor1" Runat="server"   
                    Content='<%# Bind("LogEntry") %>'>  
                    <Content> 
</Content> 
                </telerik:RadEditor> 
            </EditItemTemplate> 
            <ItemTemplate> 
                
                <asp:ImageButton ID="ImageButton1" runat="server" CommandName="Edit" ImageUrl="~/images/Edit.gif" ToolTip="Click to view the log entry" /> 
               
            </ItemTemplate> 
        </telerik:GridTemplateColumn> 
                   <telerik:GridButtonColumn ConfirmText="Delete this Entry?" ConfirmDialogType="RadWindow" 
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" 
                        UniqueName="DeleteColumn">  
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" /> 
                    </telerik:GridButtonColumn> 
 
    </Columns> 
 
<EditFormSettings> 
<EditColumn UniqueName="EditCommandColumn1" ButtonType="ImageButton"></EditColumn> 
</EditFormSettings> 
</MasterTableView> 
    </telerik:RadGrid> 
   

 

What I would like is for  CurrDateLbl to have the current date in it when the user clicks "Add New Record"

What event do I put that in?  ItemCommand fires at the right time, but I don't seem to be able to reference CurrDateLbl in that event.

Eric

 

Pam
Top achievements
Rank 2
 answered on 14 Sep 2012
2 answers
135 views
Hi,
My problem is:
I have a master page where I have RadAjaxManager and RadScriptManager.
On my aspx page I need to call with a javascript function the server with a Ajaxrequest to update a label for example.
For that, I added a RadAjaxManagerProxy and RadCodeBlock.
When I click on the button1, that working.
Form the button2 (javascript), I called the function manager_AjaxRequest but don't refresh the label.
Do you know what I missed ?
Here is a copy of my master page and detail page.

Masterpage:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="test.master.cs" Inherits="abc.pages.MasterPage.test"  ClientIDMode="AutoID" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManagerMasterPage" runat="server" />
    <telerik:RadAjaxManager ID="RadAjaxManager_Master" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"></telerik:RadAjaxManager>
    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server" />
    </form>
</body>
</html>

Code begin:
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
 
}

Detail page:
<telerik:RadAjaxManagerProxy ID="AjaxManagerProxy1" runat="server" >
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="Button1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="Label1"
                    LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="Button2">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="Label1"
                    LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>
 
<telerik:radajaxloadingpanel id="RadAjaxLoadingPanel1" runat="server" skin="Windows7" />
 
    <telerik:RadCodeBlock  ID="RadScriptBlock1" runat="server">
    <script type="text/javascript">
        function test() {
            var manager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>");
            var textBoxId = "RowSelected";
            if (manager && textBoxId) {
                manager.ajaxRequest("RowSelected");
            }
        }
    </script>
</telerik:RadCodeBlock >
 
<asp:Button ID="Button1" runat="server" Text="test 1" onclick="Button1_Click" /><br />
<asp:Button ID="Button2" runat="server" CausesValidation="false" OnClientClick="javascript:test();return false;" Text="test 2" /><br />
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>

and the code behind:
protected void Page_Load(object sender, EventArgs e)
{
    RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
    manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(manager_AjaxRequest);
}
 
protected void Button1_Click(object sender, EventArgs e)
{
    Label1.Text = "A" + DateTime.Now.Ticks.ToString();
}
 
protected void manager_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
    if (e.Argument == "RowSelected")
    {
        Label1.Text = "B" + DateTime.Now.Ticks.ToString();
    }
}
daniel demesmaeker
Top achievements
Rank 1
 answered on 14 Sep 2012
5 answers
570 views
 Hi all,

I have a grid with 3 columns, a name and a date and a calculated (sql) field witch displays terms like "last week, this week, today, yesterday, next week, last year, etc..."

When i use a grouping al works fine, only the group sorting is alphabetical (of course) and thus the wrong order. I would like the grid toe group, but sort the groups logical, on the date field.

any ideas?

Thanks in advance!
Joe
Top achievements
Rank 1
 answered on 14 Sep 2012
1 answer
119 views
Hi,
I am showing daily test results over a period of time in a line chart.
The values varriy from 0% to 100%. 100% means bestand 0% means the worst.

Currently my chart line is all green. I wanted to check if I can have gradient like color which show 0% red and 100% as green and any other percentage from 0 to 100 are represented by the color which flows form red to green.

Can I achieve this?

Thanks,
Abinash
Petar Kirov
Telerik team
 answered on 14 Sep 2012
3 answers
174 views
The treelist has autogenerated columns and bound to a datatable.

I read somewhere that you need to set the width in order to get the exporting to work.  THis is the error that i'm getting:


System.SystemException: At least one of minimum, optimum, or maximum IPD must be specified on table.

Daniel
Telerik team
 answered on 14 Sep 2012
2 answers
81 views
Hi,

I'd like to have a single menu instance on a single web page.  And as I click on a menu option, A different user control is loaded into the web page.  I didn't see any samples for this.  Is this something that is possible?

Thanks,
Craig
Craig
Top achievements
Rank 1
 answered on 14 Sep 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
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
Iron
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?