We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid with click of server fail

Thread ID:

Created:

Updated:

Platform:

Replies:

124153 May 20,2016 04:24 PM UTC Sep 5,2016 05:42 AM UTC ASP.NET Web Forms 10
loading
Tags: Grid
Roimer Machacón Otero
Asked On May 20, 2016 04:24 PM UTC

Hi we're using grid with UrlAdaptor. Now have this problem:

The data for load in the grid depend of a number, in the attached example used 1 with another number no brings data.

Now in the example have 2 buttons, when clicked the new button (paper sheet) assigned 2 and no brings data, to the no brings data the grid render fail.

Now when clicked the cancel button (x button) assigned 1 and bring data and the grid render correctly.


Attached the example project and images where show the error.

Attachment: errorgrid_bf5d7890.rar

Venkatesh Ayothi Raman [Syncfusion]
Replied On May 23, 2016 01:00 PM UTC

Hi Roimer, 

Thanks for contacting Syncfusion support. 

We were unable to reproduce the issue at our end. We have created a sample for your convenient. In this sample, we have bound the datasource using URL adaptor with ejTab panel.  
Please refer to the following sample, 


Screenshot:  

If you still face the same issue then could you please provide the following details? 
1) Essential studio version details and browser details. 
2) Scenario for replication procedure 
3) Modify the given sample as issue reproducible. 
4) Why you are extending the URL adaptor? Provide the more details. 

Regards, 
Venkatesh Ayothiraman. 


Roimer Machacón Otero
Replied On May 23, 2016 02:15 PM UTC

Hi, the example work but not is equal to our request as we need to implement.

We need implement the load data depending on a external value in a textbox. In the example that we sent put this value in a hiddenfield, in our application is in a textbox.

We seeing the example sent for you don't use the value change that we are using. With this can see the scenario is different

Venkatesh Ayothi Raman [Syncfusion]
Replied On May 24, 2016 02:41 PM UTC

Hi Roimer, 

Thanks for the update. 

We have created a following sample for your requirement. In this sample, we have enabled two buttons and one hidden field which is default value is “1”. We can change the value on server side while clicking the buttons as well as we can load the different datasource. Please refer to the code example and sample, 
Code Example: 
[WebMethod] 
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)] 
        public static  object Cargar3(int skip, int take, string codigo) 
        { 
            IEnumerable<Order> listaDetalles; 
            if (codigo == "1") 
                listaDetalles = new Nwind1DataContext().Orders.ToList(); 
            else 
                listaDetalles = new Nwind1DataContext().Orders.Take(1).ToList(); 
            
            DataResult result = new DataResult(); 
            result.result = listaDetalles.Skip(skip).Take(take).ToList(); 
            result.count = listaDetalles.Count(); 
            return result; 
             
        } 
 
        protected void ibtnNuevo_Click(object sender, System.Web.UI.ImageClickEventArgs e) 
        { 
             
            hdfCodigo.Value = "2"; 
        } 
 
        protected void ibtnCancelar_Click(object sender, System.Web.UI.ImageClickEventArgs e) 
        { 
 
            hdfCodigo.Value = "1"; 
        } 


  
 Please refer to the KB documentation for URL adaptor server side datamanager operation, 

Regards, 
Venkatesh Ayothiraman. 


Roimer Machacón Otero
Replied On May 24, 2016 07:51 PM UTC

Hi, 

We see the example, now in both case the IEnumerable<Order> listaDetalles; brings data. Our problem is when of the database the value with that filter bring the IEnumerable without data. In this point is when the render of the grid fail.

Roimer Machacón Otero
Replied On May 24, 2016 07:58 PM UTC

Try an example when the filter (value in the hiddenfield or textbox) make that the enumerable not bring data, previously attached an sample project showing the error

Venkatesh Ayothi Raman [Syncfusion]
Replied On May 25, 2016 05:33 PM UTC

Hi Roimer, 

Sorry for the inconvenience. 


We have created a sample using data table. In this sample, we have bound the data to grid using data table with using hidden field value.  

Code example: 

 
public static object Cargar1(int skip, int take, string codigo) 
        { 
 
            implementacion implementacion = new implementacion(); 
            var listaDetalles = implementacion.listar(codigo); 
            DataResult result = new DataResult(); 
            result.result = listaDetalles.Skip(skip).Take(take).ToList(); 
            result.count = listaDetalles.Count(); 
            return result; 
        } 
        [WebMethod] 
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)] 
        public static object Cargar2(int skip, int take, string codigo) 
        { 
 
            implementacion implementacion = new implementacion(); 
            var listaDetalles = implementacion.listar(codigo); 
            DataResult result = new DataResult(); 
            result.result = listaDetalles.Skip(skip).Take(take).ToList(); 
            result.count = listaDetalles.Count(); 
            return result; 
        } 
        [WebMethod] 
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)] 
        public static  object Cargar3(int skip, int take, string codigo) 
        { 
            implementacion implementacion = new implementacion(); 
            var  listaDetalles = implementacion.listar(codigo); 
            DataResult result = new DataResult(); 
            result.result = listaDetalles.Skip(skip).Take(take).ToList(); 
            result.count = listaDetalles.Count(); 
            return result; 
             
        } 
 
        protected void ibtnNuevo_Click(object sender, System.Web.UI.ImageClickEventArgs e) 
        { 
             
            hdfCodigo.Value = "2"; 
        } 
 
        protected void ibtnCancelar_Click(object sender, System.Web.UI.ImageClickEventArgs e) 
        { 
 
            hdfCodigo.Value = "1"; 
        } 



If codigo value is 1 then we can bound the datasource like as follows, 

public  class implementacion 
      { 
 
          List<entidad> lista = new List<entidad>(); 
          public List<entidad> listar(string codigo) 
            { 
                 
 
              if (codigo == "1") 
              { 
              
                  entidad obj = new entidad(); 
                  //DataTable table = new DataTable(); 
                  DataTable table = new DataTable(); 
                  table.Columns.Add("OrderID", typeof(int)); 
                  table.Columns.Add("CustomerID", typeof(string)); 
                  table.Columns.Add("EmployeeID", typeof(int)); 
                  table.Columns.Add("Freight", typeof(int)); 
                  table.AcceptChanges(); 
                   
                      table.Rows.Add(25, "Indocin", 1, 100); 
                  table.AcceptChanges(); 
                  foreach (DataRow row in table.Rows) 
                  { 
                      obj.OrderID = row.Field<int>("OrderID"); 
                      obj.CustomerID = row.Field<string>("CustomerID"); 
                      obj.EmployeeID = row.Field<int>("EmployeeID"); 
                      obj.Freight = row.Field<int>("Freight"); 
                      //lista.Add(obj); 
                  } 
 
                  lista.Add(obj); 
              } 


Note: Here lista is non static method, so lista is not maintain the last value. We suggest you either you can change the lista as static or need to bind the data. In the following sample we can checked codigo as 2 and bound the data. Please refer to the code examples, 


 
if (codigo == "2") 
              { 
 
                  entidad obj = new entidad(); 
                  //DataTable table = new DataTable(); 
                  DataTable table = new DataTable(); 
                  table.Columns.Add("OrderID", typeof(int)); 
                  table.Columns.Add("CustomerID", typeof(string)); 
                  table.Columns.Add("EmployeeID", typeof(int)); 
                  table.Columns.Add("Freight", typeof(int)); 
                  table.AcceptChanges(); 
                  table.Rows.Add(15, "Indocinxx", 11, 1001); 
                  table.AcceptChanges(); 
                  foreach (DataRow row in table.Rows) 
                  { 
                      obj.OrderID = row.Field<int>("OrderID"); 
                      obj.CustomerID = row.Field<string>("CustomerID"); 
                      obj.EmployeeID = row.Field<int>("EmployeeID"); 
                      obj.Freight = row.Field<int>("Freight"); 
                      //lista.Add(obj); 
                  } 
 
                  lista.Add(obj); 
              } 
             

If we misunderstood your query then could you please share the scenario for replication procedure or modify the given sample as issue reproducible. 




Regards, 

Venkatesh Ayothiraman. 


Roimer Machacón Otero
Replied On May 26, 2016 10:47 PM UTC

Hi, attached two samples where the grid fail

Attachment: Error_grid_35ad71e2.zip

Venkatesh Ayothi Raman [Syncfusion]
Replied On May 27, 2016 12:16 PM UTC

Hi Roimer, 

Thanks for the update. 

We have validate the sample as modified by you. In that you are commented the second part of the condition. For this reason, the list returns the null value when we click the new button. In this case grid renders fail, because grid needs columns or datasource.  
Grid control renders from schema definition of columns or datasource. So columns or datasource should need to render the grid. Please refer to the following screenshot, 

Screenshot 1: Before declaring the columns and click the New button 
 
   
Code example: 
<ej:Grid ID="Grid3" runat="server" AllowGrouping="false" MinWidth="700" AllowSelection="true" TabIndex="-1" Locale="es-ES" 
                                        Selectiontype="Single" AllowSorting="false" AllowPaging="true" AllowFiltering="false" IsResponsive="true" 
                                        AllowScrolling="false" AllowResizing="true" ClientIDMode="Static"> 
                                        <ClientSideEvents Load="loadHandler" ActionBegin="actionBegin" RowSelected="seleccionada" /> 
                                        <DataManager URL="Default.aspx/Cargar1" Adaptor="UrlAdaptor" /> 
                                        <GroupSettings EnableDropAreaAutoSizing="False"></GroupSettings> 
                                        <PageSettings PageCount="10" /> 
                  Here i was commented the grid columns so grid renders fail.                     <%--<Columns> 
                                            <ej:Column Field="OrderID" HeaderText="OrderID" IsPrimaryKey="true" Width="20%" Visible="true" /> 
                                            <ej:Column Field="CustomerID" HeaderText="CustomerID" Width="80%" Visible="true" /> 
                                            <ej:column Field="EmployeeID" HeaderText="EmployeeID" Width="80%"></ej:column> 
                                            <ej:column Field="Freight" HeaderText="Freigth" Width="80" ></ej:column> 
                                        </Columns>--%> 
                                    </ej:Grid> 
 
 
                                </div> 
                            </div> 
                        </div> 
                        <div class="tab-pane" id="tab2"> 
                           . . . . 

Screenshot 2: After declaring the columns and click the new buttons. 
 

Code example: 
 
<ej:Grid ID="Grid3" runat="server" AllowGrouping="false" MinWidth="700" AllowSelection="true" TabIndex="-1" Locale="es-ES" 
                                        Selectiontype="Single" AllowSorting="false" AllowPaging="true" AllowFiltering="false" IsResponsive="true" 
                                        AllowScrolling="false" AllowResizing="true" ClientIDMode="Static"> 
                                        <ClientSideEvents Load="loadHandler" ActionBegin="actionBegin" RowSelected="seleccionada" /> 
                                        <DataManager URL="Default.aspx/Cargar1" Adaptor="UrlAdaptor" /> 
                                        <GroupSettings EnableDropAreaAutoSizing="False"></GroupSettings> 
                                        <PageSettings PageCount="10" /> 
 
                                       <Columns> 
                                            <ej:Column Field="OrderID" HeaderText="OrderID" IsPrimaryKey="true" Width="20%" Visible="true" /> 
                                            <ej:Column Field="CustomerID" HeaderText="CustomerID" Width="80%" Visible="true" /> 
                                            <ej:column Field="EmployeeID" HeaderText="EmployeeID" Width="80%"></ej:column> 
                                            <ej:column Field="Freight" HeaderText="Freigth" Width="80" ></ej:column> 
 
                                        </Columns> 
 
                                    </ej:Grid> 

 
If you still facing the same issue, then could you please provide the more details for your requirement? 
                                                                                                                                                             
 
Regards, 
Venkatesh Ayothiraman. 


Roimer Machacón Otero
Replied On September 2, 2016 09:06 PM UTC

Hi, I commented that the problem persist, exist a form of clean the grid when the datasource used in the datamanager is empty, for that the grid not fail to render?

Attached image with another grid with the same error

Attachment: grid_not_clean_data_7d12168f.zip

Mohammed Farook J [Syncfusion]
Replied On September 5, 2016 05:42 AM UTC

Hi Roimer,  
We have validated your reported issue and we are unable to reproduced at our end. Please find the sample. 
 
 
Still you facing same issue, please send the sample with your reported issue.  
 
Regards, 
J.Mohammed Farook 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;