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

I'm using RadGrid and FilterTemplates in order to have a range of dates. When the user select from date "01/01/2012" and to date "10/01/2012" this filter all records that were made during that range of time. however, is excluding all those transaction that occurred the First and the tenth.

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx  (Based on this sample)

I have defined DateFormatString as "MM/dd/yyyy" and is still excluding records. My query return datetime types meaning that the Date field is return date and time.

So how can I tried to convert them into string but is not filter correctly because it doesn't filter the year only days and months.

SO I would really appreciate your help or advice in this matter. Because I want to include those record that were made on January First and in the Tenth.
 
Victor
Top achievements
Rank 1
 answered on 30 Mar 2012
1 answer
67 views
Hello,

I have an ajaxified rad grid with a column that holds a delete button.  When the button is clicked, i rebind the grid to the datasource and then I disable some checkboxes.

When this happens, these checkboxes are not disabled.

Here is my grid:
<telerik:RadGrid ID="dgLoginRequest" 
                                                                 runat="server" 
                                                                 AllowSorting="True"
                                                                 AllowPaging="True" 
                                                                 AllowAutomaticUpdates="True"
                                                                 Skin="WebBlue" 
                                                                 EnableAJAX="true"
                                                                 EnableOutsideScripts="true" 
                                                                 GridLines="None"
                                                                 GroupingSettings-GroupContinuesFormatString="" 
                                                                 OnPageIndexChanged="dgLoginRequest_PageIndexChanged"
                                                                 OnItemDataBound="dgLoginRequest_ItemDataBound" 
                                                                 OnNeedDataSource="dgLoginRequest_NeedDataSource">
                                                      
                                                    <ClientSettings>
                                                        <Selecting CellSelectionMode="None" AllowRowSelect="False" />
                                                    </ClientSettings>
  
                                                    <MasterTableView AllowAutomaticDeletes="True"
                                                                     AllowAutomaticUpdates="True" 
                                                                     AutoGenerateColumns="False"
                                                                     CommandItemDisplay="None"
                                                                     DataKeyNames="EntityID" 
                                                                     Width="100%">
                                                          
                                                    <CommandItemSettings ExportToPdfText="Export to PDF" />
                                                    <RowIndicatorColumn>
                                                        <HeaderStyle Width="20px" />
                                                    </RowIndicatorColumn>
                                                    <ExpandCollapseColumn>
                                                        <HeaderStyle Width="20px" />
                                                    </ExpandCollapseColumn>
                                                      
                                                        <Columns>
                                                          
                                                            <telerik:GridBoundColumn DataField="EntityID" HeaderStyle-HorizontalAlign="Center" HeaderText="Entity ID" ItemStyle-HorizontalAlign="Left" SortExpression="EntityID" Visible="False" UniqueName="EntityID">
                                                                <HeaderStyle HorizontalAlign="Center" />
                                                                <ItemStyle HorizontalAlign="Left" />
                                                            </telerik:GridBoundColumn>
  
                                                            <telerik:GridBoundColumn DataField="EntityName" HeaderText="Entity Name" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" SortExpression="EntityName" UniqueName="EntityName">
                                                                <HeaderStyle HorizontalAlign="Center" />
                                                                <ItemStyle HorizontalAlign="Left" />
                                                            </telerik:GridBoundColumn>
                                                                                                                          
                                                            <telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center">
                                                                <HeaderTemplate>
                                                                    <asp:CheckBox id="headerReaderChkbox" runat="server" Text="Reader"></asp:CheckBox>
                                                                </HeaderTemplate>
  
                                                                <ItemTemplate>
                                                                    <asp:CheckBox ID="chbxReader" runat="server" Checked='<%# Eval("IsReader") %>' />
                                                                </ItemTemplate>
                                                            </telerik:GridTemplateColumn>
  
                                                            <telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center">
                                                                <HeaderTemplate>
                                                                    <asp:CheckBox id="headerDropboxChkbox" runat="server" Text="RK Dropbox"></asp:CheckBox>
                                                                </HeaderTemplate>
  
                                                                <itemtemplate>
                                                                    <asp:CheckBox ID="chbxRKDropbox" runat="server" Checked='<%# Eval("IsRKDropbox") %>' />
                                                                </itemtemplate>
                                                            </telerik:GridTemplateColumn>
  
                                                            <telerik:GridTemplateColumn HeaderText=" ">
                                                                <ItemTemplate>
                                                                    <asp:ImageButton ID="btnDelete" 
                                                                                     runat="server" 
                                                                                     CausesValidation="False"
                                                                                     ImageUrl="../Login/Images/Delete.gif"  
                                                                                     ToolTip="Delete Record" 
                                                                                     OnClick="btnDelete_Click"/>
                                                                </ItemTemplate>
                                                            </telerik:GridTemplateColumn>
  
                                                        </Columns>
                                                          
                                                        <GroupByExpressions>
                                                            <telerik:GridGroupByExpression>
                                                                <GroupByFields>
                                                                    <telerik:GridGroupByField FieldName="FamilyName" />
                                                                </GroupByFields>
                                                                <SelectFields>
                                                                    <telerik:GridGroupByField FieldName="FamilyName" FieldAlias="FamilyName" HeaderText="FamilyName" />
                                                                </SelectFields>
                                                            </telerik:GridGroupByExpression>
                                                        </GroupByExpressions>
  
                                                        <EditFormSettings>
                                                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                                            </EditColumn>
                                                        </EditFormSettings>
  
                                                    </MasterTableView>
                                                    <FilterMenu EnableTheming="True" Skin="WebBlue">
                                                        <CollapseAnimation Duration="200" Type="OutQuint" />
                                                    </FilterMenu>
                                                </telerik:RadGrid>

Here is my delete click
protected void btnDelete_Click(object sender, EventArgs e)
        {

                var

 

 

dataItem = (sender as ImageButton).NamingContainer as GridDataItem;

 

 

 

 

                foreach (EntityUserRole item in DataSource)

 

 

 

                    if (int.Parse(dataItem.GetDataKeyValue("EntityID").ToString()) == item.EntityID)

 

                    {

                        DataSource.Remove(item);

                        BindDataGrid();

 

 

                        break;

 

                    }


            foreach (GridDataItem row in dgLoginRequest.MasterTableView.Items)
            {
                var entityID = (int) row.GetDataKeyValue("EntityID");
                var chbxReader = (CheckBox) row.FindControl("chbxReader");
                var chbxRKDropbox = (CheckBox) row.FindControl("chbxRKDropbox");
                var chbxPrivateReader = (CheckBox) row.FindControl("chbxPrivateReader");
                var chbxShare = (CheckBox) row.FindControl("chbxShare");
                chbxReader.Enabled = false;
                chbxRKDropbox.Enabled = false;
            }
        }

 

 

public void BindDataGrid()

 

{

    dgLoginRequest.DataSource = DataSource;

    dgLoginRequest.DataBind();

}




Why aren't these checkboxes being disabled?
Dan Harvey
Top achievements
Rank 2
 answered on 30 Mar 2012
4 answers
206 views
Hello,

I have added several checkbox columns to a grid programmatically and I was wondering how I can retrieve a reference to them from server side code.

I am adding the columns this way:
var templateColumn = new GridTemplateColumn();
templateColumn.UniqueName = role.RoleName;
templateColumn.ItemTemplate = new RoleColumn(role);
  
// add the dynamically created columns to the grid
dgLoginRequest.MasterTableView.Columns.Add(templateColumn);
  
public class RoleColumn : ITemplate
    {
  
        protected CheckBox roleCheckbox;
        private Role _role;
  
        public RoleColumn(Role role)
        {
            _role = role;
        }
  
        public void InstantiateIn(Control container)
        {
            roleCheckbox = new CheckBox { ID = "chkReader"};
            roleCheckbox.AutoPostBack = false;
            roleCheckbox.DataBinding += new EventHandler(roleCheckbox_DataBinding);
            container.Controls.Add(roleCheckbox);
        }
  
        private void roleCheckbox_DataBinding(object sender, EventArgs e)
        {
            var cBox = (CheckBox)sender;
            var container = (GridDataItem)cBox.NamingContainer;
            cBox.Checked = (bool)DataBinder.Eval((container.DataItem), "Roles[" + _role.RoleID +"]"); 
        }
  
    }


And I bind the grid to an data source (ArrayList of customObject).  On a postback, I want to be able to get a refence to the checkboxes I added.

I am using the following code but it returns me null:
foreach (GridDataItem item in dgLoginRequest.MasterTableView.Items)
            {
                var ads = item.DataItem;
                var cbx = (CheckBox) item.FindControl("chkReader");
            }

How can I get a reference to this checkbox on lets say a button click (i.e. not using the rad grid events)?
Dan Harvey
Top achievements
Rank 2
 answered on 29 Mar 2012
1 answer
86 views
I have an issue that I have been going around in circles with for a little while now. I have a webform with a simple save button on it
<telerik:RadButton ID="btnSaveProduct" runat="server" Skin="Web20" Text="Save"></telerik:RadButton>

which has code for the click event
Private Sub btnSaveProduct_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveProduct.Click
If pageIsValid() = True Then
processPage()
End If
End Sub

I am running into a problem because when the user clicks on the button the btnSaveProduct_Click event is fired correctly and everything on the form is saved correctly. However, when the user tabs over to the button and clicks enter the btnSaveProduct_Click event is fired correctly but the items on the form are not saved correctly. It hits all the same code and the only difference is how the user clicks save. It almost seems like the clicking the button does a postback to the form but tabbing and clicking enter does not.

Does anyone have any insight to what the problem may be??
Casey
Top achievements
Rank 1
 answered on 29 Mar 2012
2 answers
228 views
Hi!

I could use some assistance if anyone is able to help. In my application I have a grid displaying a number of columns. There is a requirement for the users to be able to select any number of columns and then export the selected columns to PDF or Excel. To enable selection of columns, I added a checkbox into the HeaderTemplate of a GridItemTemplateColumn for each column.

By the way, the code displayed in this is a simplified version I created in an attempt to identify the issue. :)

Here is the markup for my RadGrid
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false">           
      <MasterTableView>
          <Columns>
              <telerik:GridTemplateColumn UniqueName="ID"
                  AllowFiltering="true"
                  HeaderStyle-Width="100"
                  SortExpression="ID"
                  FilterControlWidth="50"
                  HeaderText="ID">
                  <HeaderTemplate>
                      <asp:CheckBox ID="IDCheck" runat="server" CssClass="HeaderCheckBox" Text="ID" />
                  </HeaderTemplate>
                  <ItemTemplate>
                      <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
                  </ItemTemplate>
              </telerik:GridTemplateColumn>
              <telerik:GridTemplateColumn UniqueName="Name"
                  AllowFiltering="true"
                  HeaderStyle-Width="100"
                  SortExpression="ID"
                  FilterControlWidth="50"
                  HeaderText="Name">
                  <HeaderTemplate>
                      <asp:CheckBox ID="NameCheck" runat="server" CssClass="HeaderCheckBox" Text="Name" />
                  </HeaderTemplate>
                  <ItemTemplate>
                      <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                  </ItemTemplate>
              </telerik:GridTemplateColumn>
              <telerik:GridTemplateColumn UniqueName="RandomText"
                  AllowFiltering="true"
                  HeaderStyle-Width="100"
                  SortExpression="RandomText"
                  FilterControlWidth="50"
                  HeaderText="RandomText">
                  <HeaderTemplate>
                      <asp:CheckBox ID="RandomTextCheck" runat="server" CssClass="HeaderCheckBox" Text="Random" />
                  </HeaderTemplate>
                  <ItemTemplate>
                      <asp:Label ID="RandomTextLabel" runat="server" Text='<%# Eval("RandomText") %>'></asp:Label>
                  </ItemTemplate>
              </telerik:GridTemplateColumn>
          </Columns>
      </MasterTableView>
  </telerik:RadGrid>
  <asp:Button ID="PDFExportButton" runat="server" OnClick="ExportToPDF" Text="Export to PDF" />
  <asp:Button ID="ExcelExportButton" runat="server" OnClick="ExportToExcel" Text="Export to Excel" />

And here is the code behind:

public partial class Default : System.Web.UI.Page
{
    protected override void OnInit(EventArgs e)
    {
        RadGrid1.DataSource = GetDataSource();
        RadGrid1.DataBind();
 
        base.OnInit(e);
    }
     
    protected void Page_Load(object sender, EventArgs e)
    {
         
    }
 
    protected List<Person> GetDataSource()
    {
        List<Person> peeps = new List<Person>();
 
        for (int i = 0; i < 10; i++)
        {
            Person p = new Person
            {
                Name = "Test" + i.ToString(),
                ID = i,
                RandomText = DateTime.Now.Millisecond.ToString()
            };
 
            peeps.Add(p);
        }
 
        return peeps;
    }
 
    protected void ExportToPDF(object sender, EventArgs e)
    {
        RadGrid1.ExportSettings.ExportOnlyData = true;
        RadGrid1.ExportSettings.HideStructureColumns = true;
        RadGrid1.ExportSettings.IgnorePaging = true;
        //RadGrid1.ExportSettings.OpenInNewWindow = true;
        RadGrid1.MasterTableView.ExportToPdf();
    }
 
    protected void ExportToExcel(object sender, EventArgs e)
    {
        RadGrid1.ExportSettings.ExportOnlyData = true;
        RadGrid1.ExportSettings.HideStructureColumns = true;
        RadGrid1.ExportSettings.IgnorePaging = true;
        //RadGrid1.ExportSettings.OpenInNewWindow = true;
        RadGrid1.MasterTableView.ExportToExcel();
    }
}

The issue I am having is that when the columns are exported instead of the HeaderText being displayed, "False" is displayed. I've attached a screenshot of the PDF output.

To sum it up: I want the column's header text to display in the exported files instead of the text "False", but I can't figure out what I am doing wrong or if there is a better way to achieve this.

Thanks.
Kevin


kmccusker
Top achievements
Rank 1
 answered on 29 Mar 2012
14 answers
194 views
Hi,

My grid have a strange behaviour on the first load (Check the Image).

When I click on edit or I just sort a column, so that when the grid refresh after the AjaxRequest, the grid layout become correct.

So what is causing thie behaviour?

Thanks.

Sorry for my bad english.
Galin
Telerik team
 answered on 29 Mar 2012
1 answer
87 views
Hi,
I have adapted the load on demand demo to show a confirmation box before load the next control. If the control currently loaded is in "Edit mode" i want to show a confirmation box, so i use the following code: 

protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)
{
if
(isEdit)
  {
                
            RadTabStrip1.FindTabByText(LatestMenuItem).Selected = true;
            RadAjaxManager manager = RadAjaxManager.GetCurrent(this.Page);
            manager.ResponseScripts.Add("if(confirm('Are you sure?'))" + manager.ClientID + ".ajaxRequest('tab')");
  }
  else
   {
               LatestMenuItem = e.Tab.Text;
               string ctrl = e.Tab.Attributes["ctrl"] + ".ascx";
               LoadUserControl(ctrl,false);
               e.Tab.Selected = true;
     }
}

If the user click yes then i initiate an Ajax request to load the user control.

protected void ManagerAjaxRequest(object sender, AjaxRequestEventArgs e)
{
LoadUserControl(NewControlName,
true);
}

I also have the following RadAjax Settings on page:

<telerik:RadAjaxManagerProxy ID="RadAjaxManager1" runat="server" >
 <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadTabStrip1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadTabStrip1" />
                        <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                 
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadTabStrip1" />
                        <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
     
                     
 </telerik:RadAjaxManagerProxy>

If i debug the code i can see the control is loaded and added correctly, but nothing happens on the page. Any tips on load user controls in the ManagerAjaxRequest method?


Thanks.


Dimitar Terziev
Telerik team
 answered on 29 Mar 2012
1 answer
44 views
I have an issue with RadGrid in RadMultiPage in IE8. The RadMultiPage control has 5 pages (RadPageViews). RadMultiPage is associated with a RadTabStrip control for navigating between "pages" in RadMultiPage. One of the pages contains a set of RadGrid controls. Other pages contain standard asp controls. The actual "height" of the pages is defferent depending on content presented in each page but the page with RadGrid is the tallest of all. Directly below the RadMultiPage control I have a web user control that basically contains a specialized button (the user control is actualy a part of Master page definition).

We have an issue with this scenario in IE8 only. After navigating to the RadPageView containing the RadGrid, and then navigating to any other page (that is shorter) than the page containing RadGridConrol, the section of the button below the RadMultiPage and that was earlier "covered" by one of the RadGrid is not clickable (as if the RadGrid was still sitting on top of it and blocking a portion of it, or a ghost image of RadGrid was still there). This seems to be a z-index related, but we tried changing z-index property on all affected control with no luck.

Any help would be appreciated...
Maria Ilieva
Telerik team
 answered on 29 Mar 2012
22 answers
510 views
The firefox context menu is missing on right click allowing people to circumvent the RadEditor paste functions
Rumen
Telerik team
 answered on 29 Mar 2012
2 answers
232 views
I have a form I've created to map data from Excel into our SQL Server-based system.  The basic idea is that a user picks the Excel file to upload, then "maps" the data by selecting the database field then the corresponding Excel column.  Once the user has "mapped" a file, they can save that "mapping" for future use.

The data on the mapping screen consists of two columns - one an asp:Panel full of dynamically created RadTextBoxes representing the fields in the database (created from the DBSchema) and the other being a GridView of the "column headers" and the first row of data from the Excel file.  From there it's all point and click to map the data - Click on a database field then click on the Excel column. Javascript is used to populate the RadTextBox with the column information and to "remove" the row from the Excel GridView (so a column can only be mapped once).

When the user "saves" a mapping, the dynamically created RadTextBoxes are walked and rows are created in SQL Server using the name of the RadTextBox and part of the Text property.

All this works fine.

The problem I have is when the user tries to "load a mapping" that has previously been saved.  Using the routine that creates the list of RadTextBoxes, I populate the Text property with data from the DB (and set some CSS wrapping the "row").  This is where my problem lies.  I set the Text property, but the value is empty when the page is rendered.  I can set breakpoints in the code and "see" that the property is set to the proper value, but it still displays empty.

Futhermore - I can set the EmptyMessage property to the same value I'm attempting to place in the Text property and have that display. So something I'm doing is stomping on the Text property, but I just don't see it.  I've stepped line-by-line through the code and the values "hold" but just don't display - unless I take a long time stepping through the code, then it works .....

I'm not quite sure what's going on with this since I can get this to work by itself, just not in conjunction with the rest of the page.

I'm using RadControls for ASPNET AJAX Q1 2009

Here's the code for the function that creates the RadTextBoxes.  On a page by itself it works fine and with ASP:TextBox controls it works fine.  I know this probably isn't enough to go on, but there does seem to be a case when a dynamically created RadTextBox doesn't "hold" the .Text property :)

protected void FillFieldList(MappingType mtType, Guid? nguidFieldMappingID)  
{  
    DataTable dtLayout = Property.GetDBSchema();  
    RadTextBox rtxtNewTextBox;  
    FieldMappingItem fmiMappings = new FieldMappingItem();  
    StringBuilder sbControl;  
    string strMappedName = "";  
    bool bolMappedFound = false;  
 
    if ((mtType == MappingType.ReloadMapping) || (mtType == MappingType.LoadSavedMapping))  
    {  
        fmiMappings = new FieldMappingItem(nguidFieldMappingID);  
    }  
 
    foreach (DataRow drData in dtLayout.Rows)  
    {  
        if ((drData["DataTypeName"].ToString() != "uniqueidentifier") && (drData["ColumnName"].ToString() != "Created"))  
        {  
            strMappedName = string.Empty;  
            sbControl = new StringBuilder();  
            sbControl.Append("<div id=\"div");
            sbControl.Append(drData["ColumnName"].ToString());
            sbControl.Append("\" onclick=\"SelectRow('div");
            sbControl.Append(drData["ColumnName"].ToString());
            sbControl.Append("');\"");  
 
            foreach (FieldMappingDetailItem fmdiDetails in fmiMappings.Details)  
            {  
                if (fmdiDetails.FieldName == drData["ColumnName"].ToString())  
                {  
                    bolMappedFound = true;  
                    sbControl.Append(" class=\"MapFieldMapped\">");  
                    strMappedName = fmdiDetails.MappedName;  
                    break;  
                }  
            }  
 
            if (bolMappedFound)  
            {  
                bolMappedFound = false;  
            }  
            else 
            {  
                sbControl.Append(">");  
            }  
 
            this.pnlFields.Controls.Add(new LiteralControl(sbControl.ToString()));  
 
            rtxtNewTextBox = new RadTextBox();  
            rtxtNewTextBox.ID = "rtxt" + drData["ColumnName"].ToString();  
            rtxtNewTextBox.CssClass = "FormFieldMapping";  
            rtxtNewTextBox.Label = drData["ColumnName"].ToString();  
            rtxtNewTextBox.LabelCssClass = "FormLabel";  
            rtxtNewTextBox.EmptyMessage = strMappedName;  
            rtxtNewTextBox.Text = strMappedName;  
            this.pnlFields.Controls.Add(rtxtNewTextBox);  
              
            sbControl = new StringBuilder();  
            sbControl.Append("<input type=\"hidden\" id=\"hdn");
            sbControl.Append(drData["ColumnName"].ToString());
            sbControl.Append("\" value=\"");  
            sbControl.Append(rtxtNewTextBox.ClientID);  
            sbControl.Append("\" />");  
            this.pnlFields.Controls.Add(new LiteralControl(sbControl.ToString()));  
            this.pnlFields.Controls.Add(new LiteralControl("</div>"));  
        }  
    }  
}  
 
Ricardo
Top achievements
Rank 1
 answered on 29 Mar 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?