This is a migrated thread and some comments may be shown as answers.

Combox Onload demand in Grid

5 Answers 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kavya
Top achievements
Rank 2
Kavya asked on 27 Dec 2012, 11:29 PM
Hello
I upgraded Telerik Controls to DevCraft Ultimate. Radcombobox used to work with my older version now it stopped working checked the forums changed the code as per this link
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridincombobox/defaultvb.aspx?product=grid


It shows undefined

var ajxgrid =Window[Window['RadAjaxManager1'

 

]];

My old version was

<script language="javascript" type="text/javascript">
     var grid;
     function GridCreated(sender,args) {
 
         grid = sender;
     }
     //Selecting value from the
     function RowClicked(rowIndex) {
         var cellValues = this.Rows[rowIndex].KeyValues["Last"] ;
         var id = this.Rows[rowIndex].KeyValues["id"];
           if (window['comboboxId']) {
             var combo = window[window['comboboxId']];
             
             setTimeout(function () {
                 combo.SetText(cellValues);
                 combo.SetValue(id);
             }, 0);
 
 
 
         }
     }
     //Show DropDown
     function HandleOpen1(sender,eventargs) {
 
         //var inputElement = document.getElementById(combobox.InputID);
         
         if (sender.get_text().length > 1) {
                       grid.AjaxRequest(grid.UniqueID, "LoadFilteredData," + sender.get_text());
              
         }
         else {
             return false;
         }
 
 
     }
</script>

 

   <Telerik:radcomboBox  id="RadComboBox1" Width="300px" runat="server" MarkFirstMatch="True" AllowCustomText="True"
                OnClientDropDownOpening="HandleOpen1"  UseEmbeddedScripts="true"   >
                        
               <ItemTemplate>
                   <Telerik:RadGrid id="Grid" Width="295px" runat="server" EnableAJAX="true" EnableAJAXLoadingTemplate="true" PageSize="10" >
<ClientSettings >
                           <ClientEvents OnRowClick="RowClicked" OnGridCreated="GridCreated"></ClientEvents>
                           <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="250px" />
                       </ClientSettings>
                   </Telerik:RadGrid>
</ItemTemplate>
               <Items>
                   <Telerik:RadcomboBoxItem ID="RadcomboBoxItem1" runat="server"></Telerik:RadcomboBoxItem>
               </Items>
           </Telerik:radcomboBox>


it gives me error near grid.ajaxrequest.

Please help. Can you let me know what exactly I need to change.

Thank you
Kavya M

 

 

5 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 02 Jan 2013, 01:42 PM
Hi Kavya,

Probably the grid in the ajaxRequest is undefined and this causes the exception. Additionally please modify the code so that the ajaxRequest is being fired from the RadAjaxManager and not by RadGrid. As you can see in the demo the request is triggered by the manager and the rebind method is then called in the event handler. You can try out the following code snippets:

JavaScript
function HandleOpen1(sender, eventargs)
                {
                    if (sender.get_text().length > 1)
                    {
                        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("LoadFilteredData" + sender.get_text());
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }

C#
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        RadGrid grid = RadComboBox1.Items[0].FindControl("RadGrid1") as RadGrid;
        //detect the filter action
        if (e.Argument.IndexOf("LoadFilteredData") != -1)
        {
            grid.Rebind();
        }
    }
It would be best if you could send us the whole markup with the relevant code behind thus facilitating us on resolving the problem.

All the best,
Angel Petrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Kavya
Top achievements
Rank 2
answered on 02 Jan 2013, 03:29 PM
Hello Angel

My Radcombobox is inside a  <FormTemplate> in Radgrid. Then there is another radgrid as  <ItemTemplate> for radcombobox. Sorry my mistake didn't speciy this
Here is the code
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"
            RequestQueueSize="3">
                             
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
  <Telerik:RadGrid ID="RadGrid1"   Skin="WebBlue" OnItemCommand="RadGrid1_ItemCommand" OnItemDataBound="RadGrid1_ItemDataBound" OnDeleteCommand="RadGrid1_ItemDeleted" Font-Size="Small" Font-Names="Times New Roman" GridLines="None" runat="server" LoadingTemplateTransparency="10" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" 
              ShowFooter="True" AllowAutomaticUpdates="True" AutoGenerateColumns="False"  
        
<Telerik:GridBoundColumn ReadOnly="True" DataField="filenum"  HeaderText="Filenum"
                        SortExpression="filenum" UniqueName="filenum" Visible="False">
                    </Telerik:GridBoundColumn>
                      
                </Columns>
                <EditFormSettings EditFormType="Template" >
                    <EditColumn UniqueName="EditCommandColumn1" >
                    </EditColumn>
                    <FormTemplate>    
--script for handle open, grid created goes here as specified in the link.
 <telerik:RadComboBox  id="RadComboBox1" Width="300px" runat="server" MarkFirstMatch="True" AllowCustomText="True"
                OnClientDropDownOpening="HandleOpen" >
                <ItemTemplate>
                    <telerik:RadGrid id="Grid" Width="295px" runat="server" PageSize="10" >
  
</MasterTableView>
                        <ClientSettings EnableClientKeyValues="true">
                            <ClientEvents OnRowClick="RowClicked" OnGridCreated="GridCreated"></ClientEvents>
                            <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="250px" />
                        </ClientSettings>
                    </telerik:RadGrid>
                </ItemTemplate>
                <Items>
                    <telerik:RadComboBoxItem ID="RadComboBoxItem1" runat="server"></telerik:RadComboBoxItem>
                </Items>
            </telerik:RadComboBox>
</FormTemplate></EditFormSettings>
  
                <ExpandCollapseColumn Visible="False">
                    <HeaderStyle Width="19px" />
                </ExpandCollapseColumn>
                <RowIndicatorColumn Visible="False">
                    <HeaderStyle Width="20px" />
                </RowIndicatorColumn>
                  
                </MasterTableView
   
     </telerik:RadGrid>

So not sure why its not recognizing the ajaxmanager. Please let me know what i am doing wrong.
Thank you
0
Angel Petrov
Telerik team
answered on 07 Jan 2013, 02:21 PM
Hello Kavya,

Thank you for clarifying. If this is the case the ajax manager settings should be different. You could try something like this:
protected void Page_Load(object sender, EventArgs e)
    {
        if (RadGrid2.EditItems.Count > 0)
        {
            RadComboBox RadComboBox1 = (RadGrid2.EditItems[0] as GridDataItem).EditFormItem.FindControl("RadComboBox1") as RadComboBox;
            RadGrid grid = RadComboBox1.Items[0].FindControl("RadGrid1") as RadGrid;
            RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadAjaxManager1, grid, RadAjaxLoadingPanel1);
        }
    }
It would be hard to guess what is the root cause for this issue without a runnable sample. Therefore I have created a sample illustration of this scenario for you to review. Please go through the project and tell us what differs in your case. If the problem still persist please open a formal support ticket with a runnable project attached.

Regards,
Angel Petrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Kavya
Top achievements
Rank 2
answered on 07 Jan 2013, 04:45 PM
Angel

Checked the file you sent.When I debug step by step it doesn't even go into this step

if (RadGrid2.EditItems.Count > 0)

{

RadComboBox RadComboBox1 = (RadGrid2.EditItems[0] as GridDataItem).EditFormItem.FindControl("RadComboBox1") as RadComboBox;

RadGrid grid = RadComboBox1.Items[0].FindControl("RadGrid1") as RadGrid;

RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadAjaxManager1, grid, RadAjaxLoadingPanel1);

}


When I check in debug mode RadGrid2.EditItems.Count  is always 0 eventhough its in editmode. And also I open this radcombobox when

CommandItemSettings when I add

AddNewRecord


Please let me know what I am doing something wrong . I changed the code same as you sent and it still doesn't work. After Ajaxrequest it doesn't hit

Protected Sub RadGrid1_NeedDataSource(source As Object, e As GridNeedDataSourceEventArgs)



Thanks
Kavya
0
Angel Petrov
Telerik team
answered on 09 Jan 2013, 02:57 PM
Hi Kavya,

Could you ensure that all the events are properly wired? The code sample I sent was in C# but the code you provided for NeedDataSource is in VB. If you are using VB please verify that the events are properly attached. Other than that I do not see a reason that will cause this behavior. Additionally note that RadGrid2 in the example is the outer grid and RadGrid1 is the grid inside the combo box.

All the best,
Angel Petrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Kavya
Top achievements
Rank 2
Answers by
Angel Petrov
Telerik team
Kavya
Top achievements
Rank 2
Share this question
or