Client side service binding, 11 empty rows ?

10 posts, 0 answers
  1. Jeremie
    Jeremie avatar
    5 posts
    Member since:
    Oct 2012

    Posted 10 Dec 2012 Link to this post

    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.
  2. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 13 Dec 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jeremie
    Jeremie avatar
    5 posts
    Member since:
    Oct 2012

    Posted 02 Jan 2013 Link to this post

    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.
  5. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 02 Jan 2013 Link to this post

    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
  6. Albert Shenker
    Albert Shenker avatar
    551 posts
    Member since:
    Mar 2004

    Posted 21 Jan 2014 Link to this post

    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.
  7. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 24 Jan 2014 Link to this post

    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.
  8. Albert Shenker
    Albert Shenker avatar
    551 posts
    Member since:
    Mar 2004

    Posted 24 Jan 2014 Link to this post

    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.
  9. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 28 Jan 2014 Link to this post

    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.
  10. Lola
    Lola avatar
    4 posts
    Member since:
    Oct 2014

    Posted 16 Sep 2015 in reply to Radoslav Link to this post

    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

  11. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 16 Sep 2015 in reply to Lola Link to this post

    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

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017