Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
81 views
Hello guys, 

i am using a RadAjaxManager on my site to ajaxify some buttons (filter options, multiple selection possible) to filter the content of my RadGrid.

I am also using the EnableHistory Attribute of the RadAjaxManager, to jump back to the previous filter if you are clicking the Previous-Site Button in the Browser.

In Internet Explorer this is working very well. But in Firefox, Chrome or Opera the HistorySteps doesn´t have any effect.

Is there an possibility to get the EnableHistory to work in these browsers or is there any workaround? 

Thanks in advance.

Chris
Maria Ilieva
Telerik team
 answered on 27 Oct 2010
1 answer
98 views
Hello,
I am using RadCombobox in RadGrid . I have 3 item in RadCombobox. 
combobox item:
  1. Item 1
  2. Item 2
  3. Item 3

 

 

In Insert mode ,if I use "Item 1"  in first row. In second row I want to remove "Item 1" from combobox and show "Item 2" and "Item 3" in combobox.  How can I do this?

Thanks
Md Nasir Uddin
Veli
Telerik team
 answered on 27 Oct 2010
1 answer
272 views
I have a GridImageColumn. The image that is displayed is a thumbnail. I would like the user to be able to click the thumbnail to see a larger image. I have the Java to open the image in a new modal window. I have set the clientevent onrowdblclick to open the image. However, if the actuall thumbnail is clicked, the event does not fire. How can I make the onclick event fire when the thumbnail is clicked?

Here is what I have attempted so far with no luck.

<telerik:GridImageColumn AlternateText="Thumbnail" 
DataImageUrlFields="FilePath, ThumbnailName" DataImageUrlFormatString="{0}/{1}" 
DataType="System.String" FooterText="ImageColumn footer" HeaderText="" 
ImageAlign="Middle" UniqueName="vehicleimage">
<HeaderStyle Width="75px" />
</telerik:GridImageColumn>


Protected Sub rg_VehicleImages_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles rg_VehicleImages.ItemCreated
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim deleteBtn As LinkButton = DirectCast(item.FindControl("AutoGeneratedDeleteButton"), LinkButton)
        deleteBtn.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this image?')")
    End If
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim cell As TableCell = item("vehicleimage")
        Dim img As Image = TryCast(cell.Controls(0), Image)
        img.Attributes.Add("onclick", "rowclick")
    End If
End Sub

Any help much appreciated.
Marin
Telerik team
 answered on 27 Oct 2010
1 answer
116 views
Hi guys
I have enabled Automatic edit delete and insert in radgrid with sql data source. I have an external filter (radcombo) for filtering radgrid with distinct values of first three columns. Everything is working properly. But my issue is after filtering edit is not working properly. When i click on edit image button on a row in filtered grid i am getting first row in that grid instead of clicked item. I think, when i click on edit button radgrid going back to previous data source. How can I edit that particular clicked row in that grid. Here is my code. Please help anybody to clear this issue.

Ben

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGridOpenItems">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGridOpenItems" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadGridOpenItems">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGridOpenItems" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
              
            </AjaxSettings>
        </telerik:RadAjaxManager>
<telerik:RadComboBox ID="RadComboBox1" runat="server"
                MarkFirstMatch="True" EnableLoadOnDemand="True" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
 <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

            <script type="text/javascript">
                function RowDblClick(sender, eventArgs) {
                    sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
                }
            </script>

        </telerik:RadCodeBlock>

<telerik:RadGrid ID="RadGridOpenItems" runat="server" DataSourceID="SqlDataSourcePwOpenItems" AllowMultiRowEdit="true"
         ShowStatusBar="True" GridLines="None" OnItemUpdated="RadGrid1_ItemUpdated" OnItemInserted="RadGrid1_ItemInserted"
        AllowFilteringByColumn="false" AllowPaging="True" OnItemDeleted="RadGrid1_ItemDeleted"  
    AllowSorting="True" Skin="Vista" AllowAutomaticDeletes="True"  
        AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
        AutoGenerateColumns="False" ShowGroupPanel="false" >
        <ClientSettings Scrolling-AllowScroll="True" AllowColumnsReorder="True" ReorderColumnsOnClient="True">
                <Selecting AllowRowSelect="True" />
                <Scrolling AllowScroll="True" UseStaticHeaders="True" FrozenColumnsCount="0" SaveScrollPosition="True" />
                <Resizing AllowColumnResize="True" />
                <ClientEvents OnRowDblClick="RowDblClick" />

                <Selecting AllowRowSelect="True"></Selecting>
                <Scrolling AllowScroll="True" UseStaticHeaders="True"></Scrolling>
                <Resizing AllowColumnResize="True"></Resizing>
        </ClientSettings>
        <MasterTableView DataSourceID="SqlDataSourcePwOpenItems"
            AllowPaging="True" AllowSorting="True" CommandItemDisplay="Top"
             EditMode="InPlace" DataKeyNames="PWOPENITEMS_ID" AllowAutomaticDeletes="true">
                <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
 
 
        <RowIndicatorColumn>
            <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>

        <ExpandCollapseColumn>
            <HeaderStyle Width="20px"></HeaderStyle>

        </ExpandCollapseColumn>
      
       
<%--Gridview Columns--%>   
    <Columns>
        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"
            ButtonType="imagebutton" >
            <HeaderStyle Width="35px" />
        </telerik:GridEditCommandColumn>

        <telerik:GridClientDeleteColumn ConfirmText="Are you sure you want to delete the selected row?"
              HeaderStyle-Width="35px" ButtonType="ImageButton" UniqueName="column1" >

        <HeaderStyle Width="35px"></HeaderStyle>
          </telerik:GridClientDeleteColumn>

        <telerik:GridTemplateColumn DataField="OPCODE" HeaderText="OPCODE"
            SortExpression="OPCODE" UniqueName="OPCODE" AllowFiltering="false">
            <HeaderStyle Width="120px" />
<%--Convert to uppercase--%>        
            <EditItemTemplate>
                <asp:TextBox id="txtOpcode" runat="server" Text='<%# Bind("OPCODE") %>' MaxLength="3"
                    Onkeyup="javascript:this.value = this.value.toUpperCase();"></asp:TextBox>
            </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label id="lblOpcode" runat="server" Text='<%# Eval("OPCODE") %>'></asp:Label>
                </ItemTemplate>
        </telerik:GridTemplateColumn>
 .
 .column2, column3,...
 .

 </Columns>

        <EditFormSettings FormCaptionStyle-HorizontalAlign="Center">
       
            <EditColumn UniqueName="EditCommandColumn1"></EditColumn>
        </EditFormSettings>
    </MasterTableView>
</telerik:RadGrid>

 asp:sqlDataSource here
Update command, select command, insert command, delete command is here
update, insert, and delete parameters here.

Code behind

namespace Ames5.Schedule
{
    public partial class PWOPENITEMS : System.Web.UI.Page
    {
       
        public string GetConnectionString()
        {

            //sets the connection string from web config file "ConnString"

            return System.Configuration.ConfigurationManager.ConnectionStrings["AMES5DB_TESTConnectionString"].ConnectionString;
        }

        protected void Page_Load(object sender, EventArgs e)
        {

            if (!Page.IsPostBack)
            {
                SqlConnection conn = new SqlConnection(GetConnectionString());
                SqlCommand cmd = new SqlCommand("Select DISTINCT OPCODE,FLEET,SUBFLEET from  PWOPENITEMS", conn);//query to get the distinct values.

                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = cmd;
                DataSet ds = new DataSet();
                sda.Fill(ds, "tbl_data"); //nameing the table getting stored in DataSet as "tbl_data"

                string str1, str2, str3, str4;
                ArrayList MyDisplayList = new ArrayList();
                ArrayList MyValueList = new ArrayList();

                if (ds.Tables["tbl_data"].Rows.Count != 0)
                {
                    MyDisplayList.Add("ALL");
                    foreach (DataRow myRow in ds.Tables["tbl_data"].Rows)
                    {

                        str1 = myRow["OPCODE"].ToString();
                        str2 = myRow["FLEET"].ToString();
                        str3 = myRow["SUBFLEET"].ToString();
                        str4 = str1 + " " + str2 + " " + str3; //Concatinating three strings with space in between.

                        MyDisplayList.Add(str4);
                    }

                    RadComboBox1.DataSource = MyDisplayList;
                    RadComboBox1.DataBind();
                }
                else
                {
                    Response.Write("No Data");

                }

            }

           
            (RadAjaxManager.GetCurrent(this.Page) as RadAjaxManager).ResponseScripts.Add(string.Format("window['gridId'] = '{0}';", RadGridOpenItems.ClientID));

        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(GetConnectionString());
            if (RadComboBox1.SelectedItem.Text == "ALL")
            {
                string str = "SELECT * FROM PWOPENITEMS";
                SqlDataSourcePwOpenItems.SelectCommand=str;
               
                    RadGridOpenItems.DataBind();

            }
            else
            {
                string fullString = RadComboBox1.SelectedValue.ToString();

                string firstString = fullString.Substring(0, 3); //Extracting substring

                string middleString = fullString.Substring(3, 7); //Extracting substring

                string lastString = fullString.Substring(11, 1);

               
                string st = "SELECT * FROM PWOPENITEMS WHERE OPCODE = '" + firstString + "' AND FLEET = '" + middleString + "' AND SUBFLEET = '" + lastString + "'";
                SqlDataSourcePwOpenItems.SelectCommand = st;
             
                RadGridOpenItems.Rebind();

            }
        }

        protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)
        {
            GridEditableItem item = (GridEditableItem)e.Item;
            String id = item.GetDataKeyValue("PWOPENITEMS_ID").ToString();

            if (e.Exception != null)
            {
                e.KeepInEditMode = true;
                e.ExceptionHandled = true;
                SetMessage("Product with ID " + id + " cannot be updated. Reason: " + e.Exception.Message);
            }
            else
            {
                SetMessage("Product with ID " + id + " is updated!");
            }
        }

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

        protected void RadGrid1_ItemDeleted(object source, GridDeletedEventArgs e)
        {
            GridDataItem dataItem = (GridDataItem)e.Item;
            String id = dataItem.GetDataKeyValue("PWOPENITEMS_ID").ToString();

            if (e.Exception != null)
            {
                e.ExceptionHandled = true;
                SetMessage("Product with ID " + id + " cannot be deleted. Reason: " + e.Exception.Message);
            }
            else
            {
                SetMessage("Product with ID " + id + " is deleted!");
            }
        }

        private void DisplayMessage(string text)
        {
            RadGridOpenItems.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_DataBound(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(gridMessage))
            {
                DisplayMessage(gridMessage);
            }
        }

    }
}

 

Iana Tsolova
Telerik team
 answered on 27 Oct 2010
3 answers
147 views
Hello,
    I am looking for a combo box with a textbox as first item so that user can enter a text and then click on the dropdown to select a search kind ex. Starts with Ends With. This is a search condition attached to the RadGrid. Please refer to the following code. The search condition also has excel like advanced filter. Is it possible to make the first Item in the RadMenu - "All" to a editable mode?
<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="true" AutoGenerateColumns="false"
                   GridLines="None" Width="95%" AllowPaging="true" PageSize="25" OnNeedDataSource="RadGrid1_NeedDataSource">
                   <MasterTableView Width="100%" DataKeyNames="City" AllowFilteringByColumn="true" FilterItemStyle-Width="100%">
                       <Columns>
                           <telerik:GridBoundColumn DataField="City" HeaderText="City" UniqueName="City">
                               <FilterTemplate>
                                   <telerik:RadComboBox ID="RadSearchComboBox" Height="60px" AppendDataBoundItems="true"
                                       AutoPostBack="true" Text="" runat="server" OnSelectedIndexChanged="FilterCombo_SelectedIndexChanged"
                                       OnClientSelectedIndexChanged="SelectedIndexChanged" ShowDropDownOnTextboxClick="true">
                                       <Items>
                                           <telerik:RadComboBoxItem Text="All" Value="All" Style="display: none;" />
                                           <telerik:RadComboBoxItem Text="Chennai" Value="Chennai"/>
                                           <telerik:RadComboBoxItem Text="Hyderabad" Value="Hyderabad" />
                                       </Items>
                                       <HeaderTemplate>
                                          <telerik:RadMenu runat="server" ID="radM" Flow="Vertical" >
                                          <Items>
                                           <telerik:RadMenuItem Text="Select Filter">
                                               <Items>
                                                   <telerik:RadMenuItem Text="Starts With" Value="SW"></telerik:RadMenuItem>
                                                   <telerik:RadMenuItem Text="Ends With" Value="EW"></telerik:RadMenuItem>
                                               </Items>
                                           </telerik:RadMenuItem>
                                          </Items>
                                          </telerik:RadMenu>
                                       </HeaderTemplate>
                                       <ItemTemplate>
                                           <asp:CheckBox runat="server" ID="CheckBox" onclick="stopPropagation(event);" Text="">
                                           </asp:CheckBox>
                                           <asp:Label ID="lbl" runat="server" Text='<%# DataBinder.Eval(Container, "Text") %>'></asp:Label>
                                       </ItemTemplate>
                                   </telerik:RadComboBox>
                               </FilterTemplate>
                           </telerik:GridBoundColumn>
                       </Columns>
                   </MasterTableView>
                   <PagerStyle Mode="NextPrevAndNumeric" />
               </telerik:RadGrid>
Thanks,
JJ
Jayavidya
Top achievements
Rank 1
 answered on 27 Oct 2010
3 answers
127 views
Hi,
We are can click on the name of the column in the Image Manager to sort ASC and DESC.
Can we set these sorted alphabetically by default?  If yes what property we should used?
Thanks
Rumen
Telerik team
 answered on 27 Oct 2010
1 answer
70 views
If is basically to document what I found. I don't know if it is a bug or not, I believe it is just a flaw in the design. But this hopefully will save someone time by not having to troubleshoot for hours like I did.

I used the example of Excel-like RadGrid because it was exactly what I wanted. HOWEVER, it is for text only columns in a database. I found that when binding to the database without hard coding in the columns on the .aspx page the grid will imply a column type (nvarchar = textbox, float=RadNumericTextBox, etc...). This is fine, but there are different naming conventions for each.

Textboxes will have names like RadGrid1_ctl00_ctl04_ctl02, RadGrid1_ctl00_ctl04_ctl03, RadGrid1_ctl00_ctl04_ctl04, while NumericTextBox will have names like RadGrid1_ctl00_ctl04_RNTB_EmpID, RadGrid1_ctl00_ctl04_RNTB_EmpAge. This makes the navigation impossible with databases with numeric values, as in the example to move right you increment the name by one:
    Active Cell RadGrid1_ctl00_ctl04_ctl02 -> to move right increment RadGrid1_ctl00_ctl04_ctl02 becomes RadGrid1_ctl00_ctl04_ctl03.

My question is: is there a way to change the naming convention of the RadNumericTextBox without casting the column on the SQL call?

I can work around it by using Shift-tab/Tab for Left/Right and since the 3rd ctl99 subset is the row, I can move up and down. And I have not tried it yet, but I am sure you can just get the cell location (i.e. row 2, cell 3) and move it that way by getting the control id in the adjacent cell, but Just wondering if there is a way to make NumericTextBox have the same naming convention as TextBox ?  


Radoslav
Telerik team
 answered on 27 Oct 2010
1 answer
70 views
Hi,

I have a problem with the appearance of the grid.

I have two button-columns. I decide if which one is shown in OnItemBound.
When I set

dataItem["btnDeny"].Controls[0].Visible = false;

the gridlines are broken in this column after that like in the screenshot.

Nadine
Pavlina
Telerik team
 answered on 27 Oct 2010
6 answers
108 views
Not sure whether this should be posted here or the RadWindow forum.

I have a monthly Scheduler view where I add and edit entries using a RadWindow to open another page.

This all works perfectly fine, until my Monthly Scheduler grows bigger than the displayed page.  If I then scroll down and add an entry at the bottom, the RadWindow opens and is shown for a moment in the correct position as maximized, then it is shifted down so it starts half way down the browser window.

If I add an event at the top of the Calendar it all works OK.

I am using RadControls 2010.2.9.929 and IE8 (although it exhibits the behaviour in other browsers as well)

David Penny
David Penny
Top achievements
Rank 2
 answered on 27 Oct 2010
1 answer
77 views
Hi,

I have a problem in my grid (skin: Oulook).

When I select a row, some kind of half background appears in the row. I don't know if it's some kind of background color or an additional part of the header?

I attached a screenshot of unselected and selected state.

            <telerik:RadGrid ID="RadGridSourcing" Skin="Outlook"  BorderStyle="None" <br>                runat="server" OnItemCreated="RadGridSourcing_ItemCreated" <br>                OnItemCommand="RadGridSourcing_OnItemCommand" AllowMultiRowSelection="true" ClientSettings-Selecting-AllowRowSelect="true"<br>                OnNeedDataSource="RadGridSourcing_NeedDataSource"<br>                 Width="100%" OnItemDataBound="RadGridSourcing_ItemDataBound" OnPreRender="RadGridSourcing_PreRender" BorderWidth="0">                 <br>                <HeaderStyle BackColor="Blue" BorderWidth="0"/> <br>                <CommandItemStyle BackColor="White"   /><br>                <ItemStyle ForeColor="DimGray" BackColor="White"  /><br>                <ActiveItemStyle BackColor="White"  /><br>                <AlternatingItemStyle BackColor="AliceBlue" ForeColor="DimGray" /> <br>                <SelectedItemStyle BackColor="White" /> <br>                <EditItemStyle BackColor="White" />                <br><MasterTableView AutoGenerateColumns="False" ShowHeader="true" EditMode="PopUp" DataKeyNames="Guid">


Nadine
Dimo
Telerik team
 answered on 27 Oct 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?