Friday, November 18, 2011

RadComboBox EnableLoadOnDemand

Problem: I created radcombobox dynamically. I want to add EnableLoadOnDemand functionality from codebehind. I need a sample of code in asp.net having this functionality doing from codebehind.
Solution: To see how RadComboBox is bound to various data sources, you could refer to the DataBinding section of the Combo's online documentation.

To enable the load on demand functionality, you need to set the property LoadOnDemand to true, and subscribe to the OnItemsRequested server-side event, where the items will be populated when they are requested on demand (which happens when the user opens the drop-down list, or type in the input field), as in the code-block below:
protected void Page_Load(object sender, EventArgs e)
{
    RadComboBox combo = new RadComboBox();
    combo.ID = "RadComboBox1";
    combo.EnableLoadOnDemand = true;
    combo.ItemsRequested += new RadComboBoxItemsRequestedEventHandler(combo_ItemsRequested);
    form1.Controls.Add(combo);
}
protected void combo_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
    RadComboBox combo = (RadComboBox)sender;
    for (int i = 0; i <= 3; i++)
    {
        combo.Items.Add(new RadComboBoxItem("item_" + i.ToString()));
    }
}

Sunday, November 13, 2011

How to filter record on RadGrid by only one column

Problem: When i set AllowFilteringByColumn property of RadGrid to "True", all columns can be filtered. What i want to do is to filter records by only one column. How can i do that?
Solution: You can set the AllowFitering property for the every column other than the one with which you want to filter the grid to false.

Example:
<radG:GridBoundColumn AllowFiltering="false" DataField="ContactName" UniqueName="BoundColumnUniqueName" HeaderText="ContactName">
</radG:GridBoundColumn>

Friday, November 11, 2011

Remove mouse cursor from RadComboBox

Problem: How to remove the blinking mouse cursor from the RadComboBox ?
Solution: You want to prevent to type in RadComboBox. You could try setting AllowCustomText property of the RadComboBox to false which prevents typing any text in the input of the RadComboBox. Also set the EnableLoadOnDemand and MarkFirstMatch properties to false.

Thursday, November 10, 2011

Label to filter in GridTemlpateColumn

Problem: I want to filter an ASP label
"<asp:Label  runat="server" Text='<%# eval("AnyThing") %>' ></asp:Label>"
in Telerik GridTemplateColumn .Also I dont want Filter Icon to display and I Want "Contains" Filter Function.

Sloution: Just give DataField="DataFieldName" in GridTemplateColumn.The DataField Name which you are using to evaluate Label

Example:
<asp:Label ID="lblName" runat="server" Text='<%# eval("Name")></asp:Label>
Must be given to DataField e.g DataField="Name".
The Green Highlighted Text Is For Filter Icon To Hide and For Filtering With "Contains" 
The Aqua Highlighted  text is For Filtering a String From  Label

Yellow  Is Common For Both

Here Is The Sample Code:


<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"   >
           <MasterTableView  AllowFilteringByColumn="True"  >
                    <Columns>
                             <telerik:GridTemplateColumn AllowFiltering="true"   AutoPostBackOnFilter="true" HeaderText="Name" datafield="Name" DataType="System.String"
ShowFilterIcon="false"   CurrentFilterFunction="Contains" UniqueName="Name" >
                                         <ItemTemplate>
                                                   <asp:Label ID="lblName" runat="server" Text='<%# eval("Name") %>'>
                                                   </asp:Label>
                                         </ItemTemplate>
                             </telerik:GridTemplateColumn>
                    </Columns>
           </MasterTableView>
</telerik:RadGrid>
               


Wednesday, November 9, 2011

TextBox in GridTemplateColumn

Problem: I want to filter an ASP TextBox
"<asp:TextBox ID="TXTName" runat="server" Text='<%# eval("Name") %>'  ></asp:TextBox>"
in Telerik GridTemplateColumn .Also I dont want filter Icon to display and I Want "StartsWith" Filter Function.

Sloution: Just give DataField="DataFieldName" in GridTemplateColumn.The DataField Name which you are using to evaluate TextBox.

Example:
<asp:TextBox ID="TXTName" runat="server" Text='<%# eval("Name") %>'  ></asp:TextBox>
Must BE Given To DataField e.g DataField="Name".
The Green Highlighted Text Is For Filter Icon To Hide and  For Filtering With "StartsWith" 
The Aqua Highlighted text is For Filtering a String From Label

Yellow Is Common For Both

Here Is The Sample Code:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"   >
            <MasterTableView  AllowFilteringByColumn="True"  >
                     <Columns>                 
                           <telerik:GridTemplateColumn AllowFiltering="true"   AutoPostBackOnFilter="true" HeaderText="Name" datafield="Name" DataType="System.String"
ShowFilterIcon="false"   CurrentFilterFunction="StartsWith" UniqueName="Name" >
                                     <ItemTemplate>
                                        <asp:TextBox ID="TXTName" runat="server" Text= '<%# eval("Name") %>' >
                                        </asp:TextBox>
                                     </ItemTemplate>
                            </telerik:GridTemplateColumn>
                    </Columns>
            </MasterTableView>
</telerik:RadGrid>