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

[Solved] Grid Ajax Binding continuous calling Select method

4 Answers 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
USMAN
Top achievements
Rank 2
USMAN asked on 25 Jan 2012, 12:31 PM
Hi friends.

I have a Telerik Grid and I am using Ajax Binding.

One of the grid is working fine, but the same other grid is not working.

the problem is that, it continuous calling the select method which return the data to bind with grid.

my code for ajax binding (this one is not working) It Continuous calling the _SelectAjaxBinding() Method.

<%= Html.Telerik().Grid<QuestionAnswer.Models.Answers>()
        .Name("Grid")
         
        .DataKeys(keys =>
        {
            keys.Add(p => p.Answer_ID);
        })
        .ToolBar(commands =>
        {
            commands.Insert().ButtonType(GridButtonType.ImageAndText).ImageHtmlAttributes(new { style = "margin-left:0" });
        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Ajax()
                .Select("_SelectAjaxBinding", "Answer")
                .Insert("_InsertAjaxEditing", "Answer")
                .Update("_SaveAjaxEditing", "Answer")
                .Delete("_DeleteAjaxEditing", "Answer");
        })
        .Columns(columns =>
        {
            columns.Bound(p => p.Answer).Width(210);
            columns.Bound(p => p.Points).Width(210);
             
             
            columns.Command(commands =>
            {
                commands.Edit().ButtonType(GridButtonType.ImageAndText);
                commands.Delete().ButtonType(GridButtonType.ImageAndText);
            }).Width(200).Title("Commands");
        })
            .Editable(editing => editing
                .Mode(GridEditMode.InLine))
                                    .ClientEvents(events => events.OnError("onError"))//.OnEdit("onEdit"))
        .Pageable()
        .Scrollable()
        .Sortable()
%>


Controller
[GridAction]
    public ActionResult _SelectAjaxBinding()
    {
        return View(new GridModel(AnswersRepository.All()));
    }


And the following Grid is working Perfect:

<%= Html.Telerik().Grid<QuestionAnswer.Models.Que_AnsMetaData>()
        .Name("Grid")
         
        .DataKeys(keys =>
        {
            keys.Add(p => p.Que_Ans_ID);
        })
        .ToolBar(commands =>
        {
            commands.Insert().ButtonType(GridButtonType.ImageAndText).ImageHtmlAttributes(new { style = "margin-left:0" });
        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Ajax()
                .Select("_SelectAjaxBinding", "QuestionAnswer")
                .Insert("_InsertAjaxEditing", "QuestionAnswer")
                .Update("_SaveAjaxEditing", "QuestionAnswer")
                .Delete("_DeleteAjaxEditing", "QuestionAnswer");
        })
        .Columns(columns =>
        {
            //columns.Bound(p => p.Question_ID).ClientTemplate("<label> <#= Question #> </label>");
            //columns.Bound(p => p.Answer_ID).ClientTemplate("<label> <#= Answer #> </label>");
 
            columns.Bound(p => p.Question_ID);
            columns.Bound(p => p.Answer_ID);
             
            columns.Command(commands =>
            {
                commands.Edit().ButtonType(GridButtonType.ImageAndText);
                commands.Delete().ButtonType(GridButtonType.ImageAndText);
            }).Width(200).Title("Commands");
        })
            .Editable(editing => editing
                .Mode(GridEditMode.InLine))
            .ClientEvents(events => events.OnError("onError"))//.OnEdit("onEdit"))
        .Pageable()
        .Scrollable()
        .Sortable()
%>

Controller

[GridAction]
       public ActionResult _SelectAjaxBinding()
       {
           return View(new GridModel(Que_AnsRepository.All()));
       }


So Dear friends, can you please help me to point out the problem...???




4 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 25 Jan 2012, 12:42 PM
Hi Usman,

Each component on the page should use an unique name when being declared.
Changing the name of the second Grid should fix the problem.

All the best,
Petur Subev
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
USMAN
Top achievements
Rank 2
answered on 25 Jan 2012, 01:15 PM
Hi, I have changed the Grid Names. but still it continuous calling the Select Method for Ajax Binding the second grid is still working perfect.

And these grids are in Separate Views.

Sometimes even when I open the Home index view, it calls the Select method for Ajax Grid binding for Index View of Answers Controller.

and the Loading Icon on Bottom left corder of Grid continuous moving...
0
Petur Subev
Telerik team
answered on 25 Jan 2012, 01:34 PM
Hello again Usman,

In order to assist you I will need a sample project which reproduces the problem so I can check what causes it.
Thank you for the assistance and the cooperation.


Regards,
Petur Subev
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
USMAN
Top achievements
Rank 2
answered on 25 Jan 2012, 03:07 PM
Thanx for your reply.

Actually there was a problem with Circular Reference.

Now Problem Solved. Thanx.
Tags
Grid
Asked by
USMAN
Top achievements
Rank 2
Answers by
Petur Subev
Telerik team
USMAN
Top achievements
Rank 2
Share this question
or