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

RadGrid ClientEvents OnCommand property filling grid data source with garbage records.

10 Answers 137 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Max
Top achievements
Rank 1
Max asked on 04 Feb 2011, 04:16 PM

Adding the ClientEvents OnCommand property to the RadGrid will cause load the grid on the page with some empty rows. When I remove  ClientEvents OnCommand property – all works fine.

I have:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="App_test_test" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

 

     <telerik:RadScriptManager ID="scriptManagerBase" runat="server" >

        <Scripts>

        </Scripts>

    </telerik:RadScriptManager>

    <div>

        <telerik:RadGrid ID="gvClaimHistory" runat="server" AutoGenerateColumns="False" GridLines="None" AllowSorting="true" PageSize="20">                   

                    <MasterTableView Width="100%">

                        <Columns>                          

                            <telerik:GridImageColumn DataImageUrlFields="StatusURL" DataImageUrlFormatString="{0}" HeaderText="Status" UniqueName="statusCol" AllowSorting="false" />

                        </Columns> 

                        <NoRecordsTemplate>

                            <div class="important center" style="margin: 5px;">There are no current to display.</div>

                        </NoRecordsTemplate>

                    </MasterTableView>

                    <ClientSettings>                        

 

                        <

 

 

ClientEvents OnCommand="gv_Command" />          


                    </ClientSettings>

                </telerik:RadGrid>

    </div>

    </form>

    <telerik:RadCodeBlock runat="server" ID="codeBlock1">

        <script type="text/javascript">

            function gv_Command(sender, args) {

                alert('test');

            }

        </script>

    </telerik:RadCodeBlock>

</body>

</html>

See attached files with and without ClientEvents OnCommand.

Without works properly, with should work in the same way. Any suggestions how to fix it?



10 Answers, 1 is accepted

Sort by
0
Max
Top achievements
Rank 1
answered on 04 Feb 2011, 11:35 PM

Is somebody going to fix that bug or what?

0
Max
Top achievements
Rank 1
answered on 09 Feb 2011, 04:19 PM

Hey guys. Are you going to leave it like this? This is a bug and it should be fixed.

0
Iana Tsolova
Telerik team
answered on 09 Feb 2011, 05:20 PM
Hello Max,

Can you specify how is the grid bound?
Note that when the OnCommand client-side event is handled this indicates that the grid is bound client-side. In this case the grid created so items as the PageSize is plus 1 until it is bound.

Greetings,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Max
Top achievements
Rank 1
answered on 09 Feb 2011, 05:38 PM

Iana,

When the page load, initially grid is empty. Only when user changes something on the page the grid is binding client side.

This is not a real problem because I can hide the grid initially. But the huge problem with GridImageColumn in that grid. When “grid created so items as the PageSize is plus 1” the src in the IMG tag is blank and it cause Google Chrome reload page 3 times.


Max. 

0
Max
Top achievements
Rank 1
answered on 10 Feb 2011, 07:03 PM

Iana,

Why “the grid created so items as the PageSize is plus 1 until it is bound” ???

I have tried to bind a client side the empty data source in page load event to avoid blank SRC in IMG tag, but this is too late event and Google Chrome still reloading 3 times.

Then I have try to bind data empty data source code behind in page load. This is work and Google Chrome DO NOT reloading 3 times, BOT I cannot bind data source client side after that.

Is any suggestion how to fix it?

Max.

0
Iana Tsolova
Telerik team
answered on 14 Feb 2011, 02:47 PM
Hello Max,

Can you share the full page code, where you are binding the grid only client-side? I will prepare a runnable sample to see the issue with Chrome reloading the page three times. Then I can forward it to our developers so they see if this is a bug with RadGrid or if there is a suitable resolution for your case.

Kind regards,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Max
Top achievements
Rank 1
answered on 14 Feb 2011, 04:19 PM

Hello Iana,
Sure, there is a full page code:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Tests_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="scriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Path="~/js/jsAddClaims-Pre.js" />
            </Scripts>
        </asp:ScriptManager>
    <div>
        <telerik:RadGrid ID="gvTest" runat="server" AutoGenerateColumns="False" GridLines="None" 
                AllowSorting="true" PageSize="20">
            <PagerStyle Mode="NumericPages" />
            <MasterTableView Width="100%"  DataKeyNames="ClaimID" ClientDataKeyNames="ClaimID" EnableNoRecordsTemplate="true"   
                AllowMultiColumnSorting="false"  AllowNaturalSort="false">
                <Columns>
                    <telerik:GridImageColumn DataImageUrlFields="StatusURL" DataImageUrlFormatString="{0}" HeaderText="Status" UniqueName="statusCol" AllowSorting="false"  />
                </Columns>  
                <NoRecordsTemplate>
                    <div class="important center" style="margin: 5px;">There are no current claims to display.</div>
                </NoRecordsTemplate>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnCommand="test" />
            </ClientSettings>
        </telerik:RadGrid>
    </div>
        <script type="text/javascript">
            function test(sender, args) {
            }
           function pageLoad() {
                var tableView = $find("<%= gvTest.ClientID %>").get_masterTableView();
                tableView.set_dataSource("");
                tableView.dataBind();
            }           
        </script>
    </form>
</body>
</html>


Code behind:

Partial Class Tests_Default
    Inherits System.Web.UI.Page
    Protected Sub Tests_Default_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    End Sub
End Class

Place break point to Page on load event and run in Google Chrome and you will see that it is hits breakpoint 3  time.  The problem with blank SRC in IMG tag. When you remove telerik:GridImageColumn column from the grid – all works fine.

Ideally the grid should be loaded without any rows. Why do you need the PageSize is plus 1 until it is bound?

Max.


0
Iana Tsolova
Telerik team
answered on 17 Feb 2011, 02:00 PM
Hello Max,

I tested the code and was able to replicate the desribed behavior. However, after removing the grid on the page and placing the below image, the Page_Load event continued firing more than once when the page is launched in Chrome.
<asp:Image ID="Image1" runat="server" ImageUrl="" />

So it seems this is a more like browser issue. I will try performing a more in-depth investigation to see if we can find any workaround.

Regarding your last quesiton: In order the GridDataItem/GridPagerItem client-side objects to be properly created and maintained they should be created on the server. That is why with client-side binding the grid creates so items as the page size plus one GridItem for the pager. Then when the grid is bound on the client, the items are either filled with data or not displayed.

All the best,
Iana
the Telerik team
0
Nishant
Top achievements
Rank 1
answered on 20 Jul 2012, 09:02 PM
Hi,

I'm encountering the same problem, if i add the OnCommand event at the client side for a grid that is databound on sever side, the grid is filled up with blank rows.

Can you please suggest a solution/workaround.

Thanks,
Nishant
0
Pavlina
Telerik team
answered on 30 Jul 2012, 01:03 PM
Hi Nishant,

As Iana explained in one of the previous posts, when the OnCommand client-side event is handled this indicates that the grid is bound client-side. And In this case the OnCommand event is expected to retrieve the information to bind the grid. You can also notice this behaviour in the following online example:
http://demos.telerik.com/aspnet-ajax/grid/examples/client/databinding/defaultcs.aspx

In case the behaviour you have observed is different, please elaborate a bit more in the details and provide step by step instructions how we can replicate it locally.

Regards,
Pavlina
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
Max
Top achievements
Rank 1
Answers by
Max
Top achievements
Rank 1
Iana Tsolova
Telerik team
Nishant
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or