
I am using several telerik MVC extensions grid and autocomplete included. Autocomplete control is ajax binded, grid - too. When the user selects sth from the autocomplete- the grid should be populated with the data starting with the input string from the autocomplete control.
I have 3 problems - I found a solution for one of them but still wondering why it happens.
Problem 1. Not solved:
The grid client ondataBinding where I make the ajax get is called two times. Respectively the server linq query is executed twice, etc. If I want to trigger the grid population from enter on autocompete (similar to your example for twitter binding) the calls to ondataBinding are a lot more (4-5)
Problem 2. Solved (not sure the right solution, but...)
if I follow your example for ajax binding I get error: This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.
Here is my method (works when GridAction attribute is removed and the result is with JsonRequestBehavior.AllowGet)
[GridAction]
public ActionResult AjaxGridBinding(string search)
{
if (!string.IsNullOrEmpty(search))
{
Repository.EntityDiagram data = new Repository.EntityDiagram();
var result = data.GetAll<Table_4>().Where(x => x.Name.StartsWith(search));
//this one works -> return Json(result.ToList(), JsonRequestBehavior.AllowGet);
return View(new GridModel(result.ToList()));
}
List<Table_4> empty = new List<Table_4>();
//return Json(empty, JsonRequestBehavior.AllowGet);
return View(new GridModel(empty));
}
Problem 3. Not solved
With firefox I can always see there is error: prettyPrint is not defined. No side effects till now, but...?
Any help appreciated!
p.s. I am using Telerik dlls 2010.3.1110.235 version, Chrome 8.0.552.237, Firefox 3.6.13, .Net Framework 4
Attached is the test project and the database backup
15 Answers, 1 is accepted
I have examined the project you have sent us. It seems that the double binding issue is cause by a javascript error due to the call to nonexistent javascript function named prettyPrint from the ScriptRegistrar's OnDocumentReady. I guess that this function call is copied from our online demos site, however please note that it is not required and it is needed only for the demo site's functionality.
Also, you may find helpful this online demo, which illustrates an implementation of similar to the functionality in question.
Rosen
the Telerik team

Thanks for the support.
You are calling $.ajax with type set to GET. This is not allowed by default in ASP.NET MVC. To enable it you must use JsonRequestBehavior.AllowGet. You can check this blog post for additional info.
Regards,Atanas Korchev
the Telerik team

Only the grid ajax call...which is working perfectly well in another grid on the same page / tabstrip but this call fails with the same
"To allow GET requests, set JsonRequestBehavior to
AllowGet"
errors...im about to make the changes Maria made (forcing JSON, but i presumed that was what the GRIDACTION decoration and GridModel were doing??Can you please provide a small runnable sample in which this behavior can be observed?
Greetings,Rosen
the Telerik team

I can't make it work, even with json.
i allow the "get" method and i can reach the partial view of the grid in get but i cant make it work.
the grid is in a tab stripe control, maybe this is the problem?
thnx
alon
Maybe you could provide a small sample showcasing the behavior you are observing?
All the best,Rosen
the Telerik team

No need for a sample. i just copied your example for Grid Custom Ajax Binding and when i return "
View(
new GridModel() { Data = dt, Total = count });"
I get:
"
This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.
"
Another grid issue:
I understood that your view for the grid is partial so i added a partial view to my project.
when i return my custom object without custom binding and remove the GridAction attribute it all works fine but when i press a number of a page the application redirects me to the
THNX
Alon
Unfortunately, from the given description it is not clear neither about your scenario nor how you have implemented it. Therefore, please consider providing a runnable app which demonstrates the issue you are facing. Regarding the custom binding example, you may find a fully runnable version here which does not show such error.
All the best,Rosen
the Telerik team

The basic sample worked for me after removing the tab stripe.
I want the folowing to work:
"Lazy" paging- retrieve data for a single page (currently, when i press a page the site redirects to the partial view)
I need the left most column to be static
sorting in all columns
virtual paging
edit row via double click
edit column values (a kind of edit all)
Is you grid component support the above?
Please show me how to make it work in the project i sent you.
P.S: I can't send you the DB but any data will do
How can i remove the zip file from this message (it's irrelevant)?
THNX
Alon
Straight to your questions:
1. Page is redirected during paging due to incorrect script inclusion causing various script errors.
When including the grid scripts you should include the telerik.common.min.js first.
@{Html.Telerik().ScriptRegistrar().DefaultGroup(group => group
.Add(
"2011.1.414/telerik.common.min.js"
)
.Add(
"2011.1.414/telerik.grid.min.js"
)
.Add(
"2011.1.414/telerik.grid.filtering.js"
));}
Also I have noticed that the action set in grid's dataBinding Select is not configure correctly, it should be a different action which returns only JSON similar to the following:
.DataBinding(dataBinding => dataBinding.Ajax()
.Select(
"_SelectGrid"
,
"Activities"
))
[GridAction(EnableCustomBinding =
true
)]
public
ActionResult _SelectGrid(GridCommand command)
{
CreateCommonRequestsInterface();
IEnumerable dt = GetData(command);
return
View(
new
GridModel() { Data = dt, Total = count });
}
2. currently frozen columns are not supported.
3. you should set Sortable setting's SortMode to MultipleColumn.
4. currently this is not supported
5. this can be implemented with few lines of javascript using the grid's load event:
<script type=
"text/javascript"
>
function
grid_load() {
var
grid = $(
this
).data(
"tGrid"
);
$(
this
).delegate(
"tbody > tr"
,
"dblclick"
,
function
() {
grid.editRow($(
this
).closest(
'tr'
));
});
}
</script>
Note that you should also included the required scripts.
6. editing a column values across multiple rows as multiple rows editing is not supported.
Rosen
the Telerik team

About frozen columns, do you have an alternative like setting a column as a row title(like the column titles)?
How can i prevent the left most row from being edited?
Will virtual paging be supported?, if yes, when?
edit column values (a kind of edit all): Can i add a toolbar with textbox for each column to implement this?
P.S:
the edit on doubleclick code you sent me doesn't seem to work. Currently i'm downloading all of your js files so nothing is missing.
this code works:
$(
'tr:has(td)', this).live('dblclick', function (e)
{
var grid = $('#Grid').data('tGrid');
grid.editRow($(
this));
});
but i rather not stating the grid's idTHNX
Alon
- I'm afraid that this is not supported.
- not sure if I understand you correctly. Did you meant the you want a specific column to not be editable . This can be achieved by setting column it as ReadOnly. More information can be found here under Making a column read-only.
- We are planning to implement virtual scrolling for Q2 2011 release.
Rosen
the Telerik team

another 2 grid questions:
How do i set the hieght of a grid to always stay fitted to a page size (now my page size is 10 and the grid shows 4 rows with a scroll)?
How do i set a column to fit to the maximum field length so i won't need to use fixed width?
thnx
Alon
From the given descriptions I suspect that you have enabled grid scrolling functionality. However you should disable it in order to achieve the desired behavior.
If you have other questions please consider opening a separate thread as we have went way outside of the scope of initial thread's question.
Rosen
the Telerik team