Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
109 views

Hi,

I have a RadGrid with a radcombobox for the filter template. In the ASPX code I have the following:

 

<telerik:GridTemplateColumn DataField="ID_Tipo" UniqueName="ID_Tipo" <br>  
HeaderText="Tipo Usuario" DataType="System.string" FilterControlWidth="150px" <br>                        SortExpression= "ID_Tipo"
<br>                        GroupByExpression="TipoUsuario Group by TipoUsuario"><br>                            <ItemTemplate><br>
                                <%#DataBinder.Eval(Container.DataItem, "TipoUsuario")%><br>                            </ItemTemplate><br
<FilterTemplate><br
<telerik:RadComboBox ID="RCB_Filtro"<br>                                    Height="200px"<br>                                    OnClientSelectedIndexChanged="TipoUsuarioIndexChanged"<br>                                    DataSourceID="SqlDataSource1"<br>                                   
EnableAutomaticLoadOnDemand="True"<br>
CurrentFilterFunction="Contains" <br>                                    AutoPostBackOnFilter="True"<br>                                   
AppendDataBoundItems="true"<br>  
SelectedValue='<%# TryCast(Container, GridItem).OwnerTableView.GetColumn("Id_Tipo").CurrentFilterValue %>'<br>                                   
DataTextField="TipoUsuario"
DataValueField="ID_tipoUsuario"<br>                                   
runat="server" <br>                                   
EnableLoadOnDemand="True"><br>             
<Items><br>                                    
    <telerik:RadComboBoxItem Text="Todos" Value="" /><br>                                   </Items><br>                               
</telerik:RadComboBox><br>                           
<telerik:RadScriptBlock ID="RadScriptBlock3" runat="server"><br>                               
<script type="text/javascript"><br>                                   
function TipoUsuarioIndexChanged(sender, args) {<br>                                  
var tableView = $find("<%# TryCast(Container, GridItem).OwnerTableView.ClientID %>");<br>                                   
if (args.get_item().get_value() == "Todos") { tableView.filter("ID_Tipo", args.get_item().get_value(), "NoFilter");<br>                                    }<br>                                   
else {<br>                                  
tableView.filter("ID_Tipo", args.get_item().get_value(), "EqualTo");<br>                                 }<br>                           } <br>                                       
</script><br>                           
</telerik:RadScriptBlock><br>                       
</FilterTemplate>

 

The radcombobox has an associated SQlDataSource:

 

<asp:SqlDataSource <br>        runat="server"<br>        ID="SqlDataSource1"<br>        ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"<br>        ProviderName="System.Data.SqlClient" SelectCommand="SELECT [ID_tipoUsuario], [TipoUsuario] from [Tipos_usuario] ORDER By [TipoUsuario]"><br>    </asp:SqlDataSource>

 

But when I run the application, only the "All" item appears in the radcombobox. And when the "All" item is removed from the selection window, then the elements of the table are also loaded.

In the VB module there is no action defined for RadGrid_ItemDataBound or RadGrid_ItemCreated, since the load is done by SQLDataSource.

 

You can help me to see what is wrong or what I lack in the radcomobox definition. Thank you

TomShelby
Top achievements
Rank 1
 answered on 17 May 2019
4 answers
1.0K+ views

I have a simple grid that allows the user to add new contacts. Certain need to be pre-populated and set to read only so the user cannot change then.

 

I've tried using <telerik:GridBoundColumn DataField="STATUS" HeaderText="Status" ReadOnly="true"/> but this hides the column when you try to add a new contact. I've tried various different way to render the column as read only including using a prerender function and attempting to set the read only status using javascript but i'm struggling to find the correct syntax for it.

 

My full code:

 

<telerik:RadGrid RenderMode="Lightweight" runat="server" ID="RadGridContats" AutoGenerateColumns="false" AllowPaging="true"
                        OnNeedDataSource="RadGridContats_NeedDataSource" OnUpdateCommand="RadGridContats_UpdateCommand"
                        OnInsertCommand="RadGridContats_InsertCommand" >
                        <MasterTableView DataKeyNames="ContactID" CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage">
                            <CommandItemSettings AddNewRecordText="Add Contact" />
                            <Columns>
                                <telerik:GridEditCommandColumn />
                                <telerik:GridBoundColumn DataField="ContactID" HeaderText="ID" ReadOnly="true" Visible="false"
                                    ForceExtractValue="Always" ConvertEmptyStringToNull="true" />
                                <telerik:GridBoundColumn DataField="Firstname" HeaderText="First Name">
                                <ColumnValidationSettings EnableRequiredFieldValidation="true" >
                                <RequiredFieldValidator ForeColor="Red" ErrorMessage="  Please enter a first name"></RequiredFieldValidator>
                                </ColumnValidationSettings></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Lastname" HeaderText="Last Name">
                                 <ColumnValidationSettings EnableRequiredFieldValidation="true" >
                                <RequiredFieldValidator ForeColor="Red" ErrorMessage="  Please enter a last name"></RequiredFieldValidator>
                                </ColumnValidationSettings></telerik:GridBoundColumn>   
                                <telerik:GridBoundColumn DataField="Email" HeaderText="Email">
                                <ColumnValidationSettings EnableRequiredFieldValidation="true" >
                                <RequiredFieldValidator ForeColor="Red" ErrorMessage="  Enter a valid email address"></RequiredFieldValidator>
                                </ColumnValidationSettings></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Workphone" HeaderText="Phone" />
                                <telerik:GridBoundColumn DataField="Title" HeaderText="Title" />
                                <telerik:GridBoundColumn DataField="Status" HeaderText="Status" ReadOnly="true"/>
                                <%--<telerik:GridButtonColumn HeaderStyle-Width="20px" Text="&lt;img src=/_layouts/15/Styles/LeadGen/images/deactivate4.png border=0 align=absmiddle alt='Select this Item'&gt;" CommandName="Select"></telerik:GridButtonColumn>--%>
                            </Columns>
                        </MasterTableView>
                        <PagerStyle Mode="NextPrevAndNumeric" />
                    </telerik:RadGrid>

 

Any help is greatly appreciated.

Attila Antal
Telerik team
 answered on 17 May 2019
7 answers
1.0K+ views
Hi,

My project involves displaying products in RadGrid. I would like to reorder rows using RadGrid's drag and drop feature wherein after reordering the row, the order should be autosaved to the database.

Is this possible and if yes, then how? I'm looking for the code on an urgent basis. Any help on this is highly appreciated.

Many thanks,
Ritika
Vessy
Telerik team
 answered on 17 May 2019
2 answers
70 views

Hi, I need to know how I can resize the appointment to make it full fill the height of the row ?

 

 

Peter Milchev
Telerik team
 answered on 17 May 2019
3 answers
214 views
Hi,

I am using the RadToolTip on an image gallery much like your demo but I would like to add a LinkButton in the ToolTip that opens up a RadWindow. I can add the LinkButton OK but can't figure out how to open the RadWindow with it.....

Many thanks,

Jon

Eyup
Telerik team
 answered on 17 May 2019
1 answer
291 views

Hi 

I have a radgrid with the following column

  <telerik:GridButtonColumn ButtonType="ImageButton" UniqueName="delete" CommandName="Detete"  ImageUrl="../../Images/MatchIt/TrashCan_Blue.png" ItemStyle-Width="10%"></telerik:GridButtonColumn>

The delete command works perfectly, but the Post-back only fires on the second click. Is there any new known issues that may have caused this?

Thanks,

John E

Attila Antal
Telerik team
 answered on 16 May 2019
1 answer
352 views

I have built a RadGrid with a MultiColumn ComboBox nested in an EditItemTemplate column This is the ASP code for the ComboBox.  I based my design from the Telerik example from this Demo-Site

<EditItemTemplate>
                                           <telerik:RadComboBox RenderMode="Lightweight" runat="server" ID="RadComboBox1" EnableLoadOnDemand="True"
                                                   DataTextField="FullName" OnItemsRequested="RadComboBox1_ItemsRequested" DataValueField="EID" AutoPostBack="true"
                                                   HighlightTemplatedItems="true" Height="140px" Width="220px" DropDownWidth="420px"
                                                   OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
                                   <HeaderTemplate>
                                       <ul>
                                           <li class="col1">EID</li>
                                           <li class="col2">FullName</li>
                                       </ul>
                                   </HeaderTemplate>
                                    
                               </telerik:RadComboBox>
                                       </EditItemTemplate>

 

And this is the C# code behind for the Combo

protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        {
            string sql = "SELECT [EID], [FullName] from LU_Employees  WHERE FullName LIKE @FullName + '%'";
            SqlDataAdapter adapter = new SqlDataAdapter(sql,
                ConfigurationManager.ConnectionStrings["DatabaseLatentFingerpints"].ConnectionString);
            adapter.SelectCommand.Parameters.AddWithValue("@FullName", e.Text);
            DataTable dt = new DataTable();
            adapter.Fill(dt);
 
            RadComboBox comboBox = (RadComboBox)sender;
            // Clear the default Item that has been re-created from ViewState at this point.
            comboBox.Items.Clear();
 
            foreach (DataRow row in dt.Rows)
            {
                RadComboBoxItem item = new RadComboBoxItem();
                item.Text = row["FullName"].ToString();
                item.Value = row["EID"].ToString();
                item.Attributes.Add("FullName", row["EID"].ToString());
 
                comboBox.Items.Add(item);
 
                item.DataBind();
            }
 
        }

 

The comboBox works but I now need to solve the problem of showing the Selected Item when I am editing the record.  Right now when I click the edit button the ComboBox  is blank.  I read the Telerik information at This link and here is the code I used for the OnItemDataBoundHandler method;

protected void OnItemDataBoundHandler(object sender, GridItemEventArgs e)
        {
            if (e.Item.IsInEditMode)
            {
                GridEditableItem item = (GridEditableItem)e.Item;
                if (!(e.Item is IGridInsertItem))
                {
                    RadComboBox combo =
                          (RadComboBox)item.FindControl("RadComboBox1");
                    RadComboBoxItem preselectedItem = new RadComboBoxItem();
                    preselectedItem.Text = item["FullName"].Text;
                    preselectedItem.Value = item["EID"].Text;
                    combo.Items.Insert(0, preselectedItem);
                    combo.SelectedIndex = 0;
 
                }
            }
        }

 

When I run the app and click the edit link to to edit the record I get an error message When the code line "preselectedItem.Text = item["FullName"].Text;" runs.  I have taken a screen shot of the error and have attached for your review

 

Can someone please tell me what I have done wrong with this code?

Perry
Top achievements
Rank 1
 answered on 16 May 2019
1 answer
81 views

Has anyone else had to deal with this or have any recommendations for a workaround?

There is a bug with the editor that is causing it to append multiple elements with the same id.

This is reproducible in latest example pages here: https://demos.telerik.com/aspnet-ajax/editor/examples/overview/defaultcs.aspx

Steps to reproduce:

  1. Create a div(or h2, etc) element with an id in the html editor e.g. <div id="test">This id will be duplicated</div>
  2. Swap to design mode and click after the div or element you added and hit enter any number of times.
  3. Each new paragraph that is created has the id of its previous sibling e.g. <p id="test">&nbsp;</p>

This is very frustrating for content creators trying to link to sections of a document and it is obviously not valid HTML.

Rumen
Telerik team
 answered on 16 May 2019
2 answers
158 views

Dears 

  I'm confused about my Group Header, why it's generate in div, but not span like the Demos do? 

Can anyone help me what makes the different? thank you!

this is my code : 

<telerik:RadGrid ID="RadCompanyGrid" runat="server" AllowPaging="False" AutoGenerateColumns="False" Width="100%" MasterTableView-TableLayout="Fixed" MasterTableView-HorizontalAlign="Center" OnItemDataBound="RadCompanyGrid_ItemDataBound" Skin="Default" >  
                        <ClientSettings >
                            <Scrolling UseStaticHeaders="true" AllowScroll="true" />
                            <ClientEvents OnGridCreated="RadCompanyGridCreated" />                            
                        </ClientSettings>                        
                        <GroupingSettings GroupByFieldsSeparator=" " />
                        <MasterTableView Width="100%" Caption="2018å¹´02月指定目標檢討" GroupHeaderItemStyle-Wrap="true"  EnableGroupsExpandAll="true" >   
                            <GroupByExpressions>
                                <telerik:GridGroupByExpression>
                                    <SelectFields>  
                                        <telerik:GridGroupByField FieldAlias="Category" FieldName="Category" HeaderText=" " HeaderValueSeparator=" " />
                                        <telerik:GridGroupByField FieldAlias="Count" Aggregate="Count" FieldName="No" FormatString="({0} Items)" HeaderText=" " HeaderValueSeparator=" " /> 
                                    </SelectFields>
                                    <GroupByFields>
                                        <telerik:GridGroupByField FieldName="Category" SortOrder="Descending" />
                                    </GroupByFields>
                                </telerik:GridGroupByExpression>
                            </GroupByExpressions>
                            <Columns>
                                <telerik:GridBoundColumn DataField="No" FilterControlAltText="Filter 編號" HeaderText="編號" UniqueName="編號" >
                                    <HeaderStyle Width="8%" Wrap="False" HorizontalAlign="Center"  />
                                    <ItemStyle Width="8%" Wrap="False" HorizontalAlign="Left"  />
                                </telerik:GridBoundColumn>                                                            
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>

 

It's show up like MyGrid.png , But Demo's Grid show up like Demo.png.

 

 

Vera Fang
Top achievements
Rank 1
 answered on 16 May 2019
1 answer
142 views

Im tring to change the default width of my raddropdownlist but nothing changes it.

the list's width changes but the control stays the same.

How can I change it?

 

thanx

 

<telerik:raddropdownlist id="ddlprok" runat="server" width="300px" dropdownwidth="300px">.........</telerik:raddropdownlist>
Rumen
Telerik team
 answered on 16 May 2019
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?