Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
181 views

Hi there is a RadComboBox inside EditItemTemplate of RadGrid along with a Button.

I am using _ItemsRequested event just to do the search in RadComboBox but not loading the whole list into it on click of RadComboBox. 

Current functionality is:
When user click on textarea of RadComboBox, type/key-in any thing,  then only the Combo binds the searched related Items into it.

Now I want to get below functionality on button click:
when user click on textarea of RadComboBox, type/key-in any thing, and click on button..then only the Combo shall bind the searched related Items into it.

Please someone reply how to achieve it ? 

Below is code of my Current functionality:

<telerik:RadGrid ID="RGGSTAcCode" runat="server"
               ShowFooter="True" GroupingEnabled="False" ShowStatusBar="true" EmptyDataText="No record available."
               AllowAutomaticInserts="False" AllowAutomaticUpdates="False" AllowAutomaticDeletes="true"
               OnNeedDataSource="RGGSTAcCode_NeedDataSource" OnItemDataBound="RGGSTAcCode_ItemDataBound"
               OnInsertCommand="RGGSTAcCode_InsertCommand" OnDeleteCommand="RGGSTAcCode_DeleteCommand"
               OnUpdateCommand="RGGSTAcCode_UpdateCommand" OnItemCommand="RGGSTAcCode_ItemCommand">
              <mastertableview ShowHeadersWhenNoRecords="true" autogeneratecolumns="false" datakeynames="AccountCodeID" InsertItemDisplay="Top"
                insertitempageindexaction="ShowItemOnCurrentPage" ShowFooter="True" CommandItemDisplay="Top" ClientIDMode="Static">                                  
                     <Columns>
                         <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn>
 
                         <telerik:GridBoundColumn DataField="AccountCodeID" HeaderText="AccountCode ID"
                           UniqueName="AccountCodeID" ReadOnly="True">                                          
                         </telerik:GridBoundColumn>                              
 
                         <telerik:GridTemplateColumn UniqueName="AccountCode" HeaderText="Account Code">
                            <ItemTemplate>
                              <asp:Label ID="lblAcCode" runat="server" Text='<%# Eval("AccountCode")%>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                               <asp:Label ID="lblAcCode2" runat="server" Text='<%# Eval("AccountCode") + " - " + Eval("AccountDescription")%>' Visible="false"></asp:Label>
                               <telerik:RadComboBox ID="ddlAccountCode" runat="server" Height="200" Width="240" DropDownWidth="310" HighlightTemplatedItems="true" CausesValidation="true"      
                                   OnItemsRequested="ddlAccountCode_ItemsRequested" EnableItemCaching="true" ShowDropDownOnTextboxClick="false"
                                   EnableLoadOnDemand="True" ShowMoreResultsBox="true" EnableVirtualScrolling="true" MarkFirstMatch="True"
                                   Filter="Contains" AppendDataBoundItems="true" DataTextField="AccountDescription" DataValueField="AccountCodeID">
                               </telerik:RadComboBox>
                                <asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"/>
                            </EditItemTemplate>
                         </telerik:GridTemplateColumn>
 
                         <telerik:GridButtonColumn ConfirmTextFormatString="Are you sure you want to Delete {0} Account Code?" ConfirmTextFields="AccountCodeID"
                         ConfirmDialogType="RadWindow" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"></telerik:GridButtonColumn>                                                                           
                  </Columns>
                  <EditFormSettings>
                     <EditColumn ButtonType="ImageButton" />
                  </EditFormSettings>
                  <CommandItemSettings AddNewRecordText="Add new record" RefreshText="Refresh"></CommandItemSettings>
              </mastertableview>
            </telerik:RadGrid>
public DataTable GetAccCode(string CompanyCode)
{
    SqlConnection con = new SqlConnection(strcon);
    SqlCommand cmd = new SqlCommand("[Invoice].[usp_tbl_AccountCode_DL_Test]", con);
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.AddWithValue("@CompanyCode", CompanyCode);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataTable dt = new DataTable();
    try
    {
        con.Open();
        da.Fill(dt);
        con.Close();
    }
    catch (Exception ex)
    {
    }
    return dt;
}
 
#region Load on Demand
private const int ItemsPerRequest = 50;
 
private static string GetStatusMessage(int offset, int total)
{
    if (total <= 0)
    {
        return "No matches";
    }
    else
    {
        return String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", offset, total);
    }
}
 
protected void ddlAccountCode_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
        //Allow only search in RadComboBox, do not load whole List item initially on combobox click
        RadComboBox combo = (RadComboBox)sender;
        string c = ddlCompany.SelectedValue.ToString();
        DataTable dt = new DataTable();
        string txt = e.Text;
 
        int itemOffset=0;
        int endOffset=0;
       
        if (txt == String.Empty)
        {
            combo.ShowDropDownOnTextboxClick = false;
        }
        else
        {
            dt = GetAccCode(c); //got all Items related to selcted company in dt
            DataView dv = new DataView(dt);
            dv.RowFilter = string.Format("AccountDescription LIKE '%{0}%'", txt);
            dt = dv.ToTable();
 
            int a = dv.Count; //get the filtered/searched items
            if (dv.Count > 0)
            {
                itemOffset = e.NumberOfItems;
                endOffset = Math.Min(itemOffset + ItemsPerRequest, dt.Rows.Count);
                e.EndOfItems = endOffset == dt.Rows.Count;
            }
            else if (a <= 0)
            {
                itemOffset = e.NumberOfItems;
                endOffset = Math.Min(a, a);
                e.EndOfItems = endOffset == a;
            }
        }
 
        //code adds/bind the records inside Combo
        for (int i = itemOffset; i < endOffset; i++)
        {
            combo.Items.Add(new RadComboBoxItem(dt.Rows[i]["AccountDescription"].ToString(), dt.Rows[i]["AccountDescription"].ToString()));
        }
 
        //If search/key-in text is not empty, show only searched records no. in footer of Combo
        if (!string.IsNullOrEmpty(e.Text))
        {
            DataView dv = new DataView(dt);
            int num = dv.Count;
            endOffset = dv.Count;
        }
        else
        {
            combo.ShowDropDownOnTextboxClick = false;
        }
        e.Message = GetStatusMessage(endOffset, dt.Rows.Count);   
}
#endregion
 
protected void btnSearch_Click(object sender, EventArgs e)
{
 
}
 

 

 

 

Nencho
Telerik team
 answered on 10 Sep 2015
11 answers
835 views
Hello, i have a question. How I can get the value of a Cell in a RadGrid and pass it to a RadTextBox selecting the RadGrid Row?
Thank you.
Eyup
Telerik team
 answered on 10 Sep 2015
1 answer
179 views

Developing Environment: Windows 10 + ASP.net 4.0 + UI for ASP.NET AJAX 2015.2.729.40
Target Server: Windows Server 2003 SP2

I'm originally using UI for ASP.NET AJAX 2010.3.1317.40 and installed 2015.2.729.40. After ​that, I can not upload image in ImageManager of RadEditor. After multiple testing, I found that it's because the ​async uploading feature. The feature is on by default in the new version, so it will use /App_Data/RadUploadTemp for temp storage, but the permission is Read/Execute o​riginally. After setting the permission to the temp folder, I can now upload image, but uploaded image didn't get focused automatically.I have to page down to find the image since there are lots of files. I set ImageManager.EnableAsyncUpload to false to workaround the problem. Why it's not focused after async-uploading?

Besides, I suggest to update online document (http://docs.telerik.com/devtools/aspnet-ajax/controls/editor/functionality/dialogs/examples/upload-images-to-the-server) aboout RadEditor, since the account used by IIS has changed from NETWORK SERVICE to <AppPoolIdentity>. And, there is nothing about the temp folder of AsyncUpload in this page. I finally found it in http://docs.telerik.com/devtools/aspnet-ajax/controls/asyncupload/overview.

Ianko
Telerik team
 answered on 10 Sep 2015
1 answer
158 views

Hello,

I have two objects. Resource (Id, Quantity, AgencyId, Agency), and Agency (Id, Name)

I made a grid that represents resources, and i want the user to edit them using the batch edit mode.

For the AgencyId, i want the user to choose from a dropdownlist.

When the user hit save, i can get the value of the Quantity but the value of AgencyId is Empty.

 

Here is my html. im i missing some thing ??

<telerik:RadGrid ID="AgenciesGrid" runat="server" AutoGenerateColumns="False" Height="280px">
               <ClientSettings EnableAlternatingItems="False">
                   <Scrolling AllowScroll="true" UseStaticHeaders="true"/>
                   <Selecting AllowRowSelect="true"/>
               </ClientSettings>
               <MasterTableView CommandItemDisplay="Top" HorizontalAlign="NotSet" EditMode="Batch" DataKeyNames="Id"
                                ClientDataKeyNames="Id" SelectMethod="GetAssociatedAgencies" UpdateMethod="UpdateAssociation"
                                InsertMethod="InsertAssociation" DeleteMethod="DeleteAssociation"
                                >
                   <Columns>
                       <telerik:GridTemplateColumn HeaderText="Agency" UniqueName="AgencyId" DataField="AgencyId">
                          <ItemTemplate>
                               <%# Eval("Agency.Name") %>
                           </ItemTemplate>
 
                           <EditItemTemplate>
                                <telerik:RadDropDownList runat="server" SelectMethod="GetAgencies" DataValueField="Id"
                                    DataTextField="Name" Width="200" />
                           </EditItemTemplate>
                       </telerik:GridTemplateColumn>
 
 
                       <telerik:GridNumericColumn HeaderText="Quantity" DataField="Quantity" DecimalDigits="0"/>
 
                        
                   </Columns>
               </MasterTableView>
           </telerik:RadGrid>

Kedjour
Top achievements
Rank 1
 answered on 10 Sep 2015
1 answer
113 views

Hi,

     We have a issue with scheduler in Ipad. If we select the moth view and try to create a appointment , it automatically ​navigates to day view. This issue is only in ipad in desktop version it works as expected. Can some  one helps to resolve this issue.  Thanks in advance!!.

 

Dimitar
Telerik team
 answered on 10 Sep 2015
3 answers
267 views

Hi,

I have upgraded the Telerik version from 2014.1 to 2015.2. Now getting an error for Jquery. As I found there are two multiple solutions:

1) Disable the UnobtrusiveValidationMode

2) Add definition for JQuery in global.asax.

 

If I choose the first option, will it affect any new functionality I will get from 2015.2 ? Which one do you recommend ?

 

Regards

Cavit
Top achievements
Rank 1
 answered on 10 Sep 2015
5 answers
555 views
I have a web application in which I generate Telerik RadGrids programatically based on some definition. Some of our datasets require custom template columns for which I have created special subclasses of GridTemplateColumn.

Some of the functions I currently override to support single selection filtering:
protected override void SetupFilterControls(TableCell cell)
 {
    base.SetupFilterControls(cell);
    cell.Controls.RemoveAt(0);
 
    var filterList = new RadComboBox();
    filterList.Width = FilterControlWidth;
    filterList.DropDownAutoWidth = RadComboBoxDropDownAutoWidth.Enabled;
    filterList.AutoPostBack = true;
    filterList.SelectedIndexChanged += filterList_SelectedIndexChanged;
    filterList.Items.Add(new RadComboBoxItem("", ""));
 
    // COMBO BOX IS POPULATED HERE -- CODE REMOVED
 
    cell.Controls.AddAt(0, filterList);
}
 
protected override void SetCurrentFilterValueToControl(TableCell cell)
{
    base.SetCurrentFilterValueToControl(cell);
    if (CurrentFilterValue != "")
    {
        (cell.Controls[0] as RadComboBox).SelectedValue = CurrentFilterValue;
    }
}
 
protected override string GetCurrentFilterValueFromControl(TableCell cell)
{
    return (cell.Controls[0] as RadComboBox).SelectedValue;
}
 
private void filterList_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
    GridFilteringItem filterItem = (GridFilteringItem)((RadComboBox)sender).NamingContainer;
 
    filterItem.FireCommandEvent("Filter", new Pair("EqualTo", UniqueName));
}

Everything here works as I expected, I am able to filter the grids by selecting an item in the radcombo box.

My question is, how can I modify this code to allow multiple selections (via the checkbox feature of the radcombo) and have my grid filter to contain the rows with any of the selected values?

The issue would seem to be with the filterItem.FireCommmandEvent. There doesn't seem to be a way to indicate an "IN" filter or ".Contains" in LINQ syntax. Is what I am trying to do not possible? I've see the example solution referenced in other threads, but that involves editing the filter expressions on the grid directly. Is that something I can do from the column itself?
Eyup
Telerik team
 answered on 10 Sep 2015
1 answer
261 views

Hi, i have a problem. 

I'm using a RadDropDownList in RadGrid when in Edit Mode. But i can't bind the datatable of list to the RadDropDownList.

here's my RadGridCode

<telerik:RadGrid ID="radGridTarget" GridLines="None" runat="server" AllowAutomaticDeletes="True"
    AllowAutomaticInserts="True" PageSize="10" Height="250px" Width="500px"
    OnItemDeleted="radGridTarget_ItemDeleted" OnItemInserted="radGridTarget_ItemInserted"
    OnItemUpdated="radGridTarget_ItemUpdated" AllowAutomaticUpdates="True" AllowPaging="True"
    AutoGenerateColumns="False" onitemdatabound="radGridTarget_ItemDataBound" >
    <MasterTableView CommandItemDisplay="Top" HorizontalAlign="NotSet" EditMode="InPlace" AutoGenerateColumns="False">
    <NoRecordsTemplate>
        <table width="100%" border="0" cellpadding="20" cellspacing="20">
            <tr>
                <td align="center">
                    <h2 style="color:Black">No Data</h2>
                </td>
            </tr>
        </table>
     </NoRecordsTemplate>
    <PagerStyle Mode="NumericPages"/>
        <BatchEditingSettings EditType="Cell" />
        <Columns>
            <telerik:GridBoundColumn DataField="Sales" HeaderText="Sales" Display="false"></telerik:GridBoundColumn>
            <telerik:GridTemplateColumn HeaderText="Target" DefaultInsertValue="Target" HeaderStyle-Width="150px" UniqueName="Target" DataField="Target">
                <ItemTemplate>
                    <%# Eval("Target") %>
                </ItemTemplate>
                <EditItemTemplate>
                    <telerik:RadDropDownList runat="server" ID="radDropDownTarget" DataValueField="Value" DataTextField="Target" ></telerik:RadDropDownList>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridNumericColumn DataField="Amount" HeaderStyle-Width="80px" HeaderText="Target Amount" SortExpression="Amount" UniqueName="Amount">
            </telerik:GridNumericColumn>
            <telerik:GridButtonColumn ConfirmText="Delete this target?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" HeaderText="Delete"
                HeaderStyle-Width="50px" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
            </telerik:GridButtonColumn>
        </Columns>
    </MasterTableView>
    <ClientSettings AllowKeyboardNavigation="true"></ClientSettings>
</telerik:RadGrid>

and this is how i bind the RadDropDownList, and not working

protected void radGridTarget_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem editItem = (GridEditableItem)e.Item;
        RadDropDownList dropDown = (RadDropDownList)editItem.FindControl("radDropDownTarget");
        dropDown.DataSource = _presenter.PopulateTargetList();
        dropDown.DataTextField = "Value";
        dropDown.DataValueField = "Desc";
        dropDown.DataBind();
    }
}
 

Please help me. Thank you in advance

Eyup
Telerik team
 answered on 10 Sep 2015
1 answer
230 views

Dear Telerik Team,

I want to import data from different websites with HTML Agility Pack. Then I want to export data to my SQL database. I have little problem because every cell return my "&nbsp" . I use method from this website:
http://www.telerik.com/forums/access-cell-values-in-radgrid-selected-index-event

So I think that problem is in import data.

I attach 2 sample code."Row" file return me correct data, but return me the same problem. I think that "Cell" sample code should return me correct data but in every rows display the same information. 

Cell Code: 

    WebClient webClient = new WebClient();
            StreamReader page = new StreamReader(WebRequest.Create("http://nolimits.art.pl/grafik/wyswietl.php?typ=2").GetResponse().GetResponseStream(), Encoding.UTF8);

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.Load(page);

            HtmlNode node = doc.DocumentNode.SelectSingleNode("//table");
            string context = node.InnerHtml;
            DataTable NLTable = new DataTable();
            //NLTable.Columns.Add(" ");//CheckBox
            NLTable.Columns.Add("Dzien tygodnia");
            NLTable.Columns.Add("Godziny zajec");
            NLTable.Columns.Add("Nazwa zajec");
            NLTable.Columns.Add("Poziom");
            NLTable.Columns.Add("Instruktor");
            NLTable.Columns.Add("Wolne miejsce dla");
            foreach (HtmlNode row in node.SelectNodes("tr"))
            {
                if (row.InnerText != "" && row.InnerHtml.IndexOf("<th>") < 0 && row.InnerHtml.IndexOf("background-color") < 0)
                {
                    TableRow tRow = new TableRow();                   
                    foreach (HtmlNode cell in row.SelectNodes("td"))
                    {
                        TableCell tCell = new TableCell();
                        tCell.Text = cell.InnerText;
                        tRow.Cells.Add(tCell);
                    }
                    NLTable.Rows.Add(tRow);
                }
            }
            rgSynchronize.DataSource = NLTable;
            rgSynchronize.DataBind();
        }

 

Cell Sample code:

WebClient webClient = new WebClient();
            //string page = webClient.DownloadString("http://nolimits.art.pl/grafik/wyswietl.php?typ=1");
            StreamReader page = new StreamReader(WebRequest.Create("http://nolimits.art.pl/grafik/wyswietl.php?typ=2").GetResponse().GetResponseStream(), Encoding.UTF8);

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.Load(page);

            HtmlNode node = doc.DocumentNode.SelectSingleNode("//table");
            string context = node.InnerHtml;
            DataTable NLTable = new DataTable();
            NLTable.Columns.Add(" ");//CheckBox
            NLTable.Columns.Add("Dzien tygodnia");
            NLTable.Columns.Add("Godziny zajec");
            NLTable.Columns.Add("Nazwa zajec");
            NLTable.Columns.Add("Poziom");
            NLTable.Columns.Add("Instruktor");
            //NLTable.Columns.Add("Nr sali");
            NLTable.Columns.Add("Wolne miejsce dla");
            foreach (HtmlNode row in node.SelectNodes("tr"))
            {
                if (row.InnerText != "" && row.InnerHtml.IndexOf("<th>") < 0 && row.InnerHtml.IndexOf("background-color") < 0)
                    NLTable.Rows.Add(row.InnerHtml);
            }
            rgSynchronize.DataSource = NLTable;
Angel Petrov
Telerik team
 answered on 10 Sep 2015
1 answer
199 views

hello, I have a radgrid with a linkbutton column "Edit". I want to call a modalextenderpopup when a user clicks the Edit button using Javascript. But it is not working:

<telerik:RadGrid ID="RadGrid_Search" runat="server" AllowPaging="True"
            AllowSorting="True" GroupPanelPosition="Top"  PageSize="30"
        ResolvedRenderMode="Classic" HorizontalAlign="Right"
            ondeletecommand="RadGrid_Search_DeleteCommand"
        onitemdatabound="RadGrid_Search_ItemDataBound"
        oneditcommand="RadGrid_Search_EditCommand">
            <MasterTableView Width="100%"  DataKeyNames="UPC">
            <EditFormSettings>
                <PopUpSettings Modal="true"/>
            </EditFormSettings>
            <Columns>
            <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete" ConfirmText="AA"></telerik:GridButtonColumn>
            <telerik:GridButtonColumn UniqueName="EditColumn" Text="Edit" CommandName="Select" ></telerik:GridButtonColumn>
            </Columns>
            </MasterTableView>
            <ClientSettings>
                <Selecting AllowRowSelect="True" />
            </ClientSettings>
            <HeaderStyle Font-Bold="True" Font-Names="Verdana" />
            <ItemStyle Font-Names="Verdana" />
                                  
        </telerik:RadGrid>
 
<cc1:ModalPopupExtender ID="popup" BehaviorID="popup1" runat="server" DropShadow="false"
        PopupControlID="pnlAddEdit" TargetControlID="lnkDummy" BackgroundCssClass="modalBackground" OkControlID="btnYes" >
    </cc1:ModalPopupExtender>

Code Behind:
if (e.Item is GridDataItem)
        {
            GridDataItem dataItem = e.Item as GridDataItem;
            string contactName = dataItem["Album Name"].Text;
 
            LinkButton button = dataItem["DeleteColumn"].Controls[0] as LinkButton;
            button.Attributes["onclick"] = "return confirm('Are you sure you want to delete " +
            contactName + "?')";
 
            LinkButton btnEdit = dataItem["EditColumn"].Controls[0] as LinkButton;
            btnEdit.Attributes["onclick"] = "return ShowModalPopup()";
        }

Javascript code :
function ShowModalPopup() {
           try
           {
               $find("popup1").show();               
           }
           catch (err) {
               alert(err.message);
           }
           return false;
       }


Please advice. Thank you

Eyup
Telerik team
 answered on 10 Sep 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?