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

Client side service binding, 11 empty rows ?

9 Answers 138 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeremie
Top achievements
Rank 1
Jeremie asked on 10 Dec 2012, 12:51 PM
Hi,

i've implemented a grid databinded with a LinqToSql datasource through client side service
I followed your documentation on demos.telerik.com or telerik.com/help but the grid displays 11 empty rows. (see attached file)

Steps to reproduce:

<telerik:RadGrid ID="RadGrid1" runat="server" Width="300" AllowPaging="True" Skin="Vista" >
        <MasterTableView>
            <PagerStyle AlwaysVisible="true" />
            <CommandItemSettings ShowAddNewRecordButton="false" />
            <Columns>
                <telerik:GridBoundColumn DataField="RefTransactionTypeID" HeaderText="Transaction Type ID"
                    SortExpression="RefTransactionTypeID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Wording" HeaderText="Wording"
                    SortExpression="Wording">
                </telerik:GridBoundColumn>
            </Columns>
             <NoRecordsTemplate>
                There are no records to display
            </NoRecordsTemplate>
        </MasterTableView>
        <ClientSettings EnableRowHoverStyle="true">
            <DataBinding SelectMethod="GetRefTransactions" SelectCountMethod="GetRefTransactionsCount" Location="Service.asmx"
                SortParameterType="Linq" FilterParameterType="Linq">
            </DataBinding>
        </ClientSettings>
    </telerik:RadGrid>


Service.asmx:
<%@ WebService Language="C#" CodeBehind="~/App_Code/Service.cs" Class="Service" %>


Service.cs:
[DataContract]
public class MyRefTransactionType
{
    [DataMember]
    public byte RefTransactionTypeID { get; set; }
    [DataMember]
    public String Wording { get; set; }
}
 
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class Service : System.Web.Services.WebService
{
    int number = 1;
    [WebMethod(EnableSession = true)]
    public List<MyRefTransactionType> GetRefTransactions(int startRowIndex, int maximumRows, List<GridSortExpression> sortExpression, List<GridFilterExpression> filterExpression)
    {
        IQueryable LinqData = DAL.getTransactionTypes(); // LinqToSql access layer
  
        GridLinqBindingData data = RadGrid.GetBindingData(LinqData, startRowIndex, maximumRows, "", "");
 
        var result = data.Data.OfType<DAL.RefTransactionType>().Select(t => new MyRefTransactionType()
        {
            RefTransactionTypeID = t.TransactionTypeID,
            Wording = t.Wording
        }).ToList();
        number = result.Count;
         
        return result;
    }
  
    [WebMethod(EnableSession = true)]
    public int GetRefTransactionsCount()
    {
        return number;
    }
}

My thought was that was not working correctly, because the grid displays 11 empty rows, but i tried to put "return new List<MyRefTransactionType>()", the grid still displays 11 emptys rows.

On page load, the get methods are never called. (breakpoints never reached)

I'm probably doing it wrong, but i can't figure what is wrong, any help ?

Thanks.

9 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 13 Dec 2012, 08:04 AM
Hi Jeremie,

Could you please try changing the SortParameterType and FilterParameterType to List and let me know if the issue still persist:
<ClientSettings EnableRowHoverStyle="true">
        <DataBinding SelectMethod="GetRefTransactions" SelectCountMethod="GetRefTransactionsCount" Location="Service.asmx"
                SortParameterType="List" FilterParameterType="List">
        </DataBinding>
</ClientSettings>

Additionally I am sending you a simple example which demonstrates the desired functionality, please check it out and let me know if it helps you. Looking forward for your reply.

Kind regards,
Radoslav
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
Jeremie
Top achievements
Rank 1
answered on 02 Jan 2013, 07:29 AM
Hi Radoslav,

Your solution works but doesn't match with my needs :

Parameters of the GetBindingData method (telerik api) accept sorting and filtering parameters only as String expressions.
public static GridLinqBindingData GetBindingData(IQueryable source, int startRowIndex, int maximumRows, string sortExpression, string filterExpression);

That's why i kept "Linq" value in SortParameterType and FilterParameterType parameters.

The solution was to change the
method parameters:
public static ResultData<Transaction> GetDataAndCount(int startRowIndex, int maximumRows, String sortExpression, String filterExpression) { ... }

Thanks a lot for your answer.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 02 Jan 2013, 08:20 AM
Hello,

Please check below link/code. This link will help you.
http://jayeshgoyani.blogspot.in/2012/08/radgrid-with-wcf-rest-service.html


Thanks,
Jayesh Goyani
0
Albert Shenker
Top achievements
Rank 1
Veteran
answered on 21 Jan 2014, 05:28 PM
I have run into this issue as well. I am not using declarative binding, but rather explicitly bind the grid client-side using a javascript call to a webservice. Is there a way to eliminate these 11 empty rows? In addition to being confusing since they look like empty data, these cause the grid to flicker right before binding to actual data.
0
Radoslav
Telerik team
answered on 24 Jan 2014, 08:18 AM
Hello Albert,

You cannot eliminate the grid rows, because they are sent from the web server. The RadGrid is server side data bound control and in order to works as expected it needs to render initial rows from the server. In this case you can try showing loading panel over the rows or you can try to set css styles to each of them. For example if you set visibility hidden and on client side databound event set visibility: visible you can prevent initially showing of empty rows. Please give it try and let me know if you experience any problems.

Looking forward for your reply.

Regards,
Radoslav
Telerik
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 the blog feed now.
0
Albert Shenker
Top achievements
Rank 1
Veteran
answered on 24 Jan 2014, 11:47 AM
I'm not quite following what you mean since I am not binding server-side. Are you saying I do need to bind to an empty collection on initial page load and somehow hide the rows in the grids server side item created event. And the show them in some client side event? If so, some provided code would be useful.
0
Radoslav
Telerik team
answered on 28 Jan 2014, 09:13 AM
Hello Albert,

I am sending you a simple example which demonstrates the described approaches in my previous reply. Please check the example and let me know if it helps you. Looking forward for your reply.

Regards,
Radoslav
Telerik
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 UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Lola
Top achievements
Rank 1
answered on 16 Sep 2015, 07:45 AM

I tried to bind radgrid client side by json object.

I get empty rows so, i used onrowdatabound client event to draw data to grid.

but, i need to draw server controls (buttons) that needed to fire item command server side event???

Is it possible?

Thank you

0
Jayesh Goyani
Top achievements
Rank 2
answered on 16 Sep 2015, 06:06 PM

Hello Lola,

Its not possible because if we execute the server side event then all the data will be lost and we have to rebind the data to radgrid.

But no need to worry we can indirectly achieve similar thing by using this.

Let me know if any concern.

Thanks, Jayesh Goyani

Tags
Grid
Asked by
Jeremie
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Jeremie
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Albert Shenker
Top achievements
Rank 1
Veteran
Lola
Top achievements
Rank 1
Share this question
or