Event to sort by a column - datatable

I've a <p:datatable> with sortable columns. I would like obtaining the event when click on header in any column.
Any idea?

What Primefaces version?? Maybe it would be for the best to create two different primefaces tags (2 and 3)...
About your solution...you know that DataTable has built-in support for ajax sorting. Means that every sort would be an ajax request, so you could intercept this ajax call. A solution to do that would be to implement an ajax status component that on start, or on complete to call a javascript function or a server side method...
Here you can find the ajax status: http://www.primefaces.org/showcase-labs/ui/ajaxStatusHome.jsf

Related

Do AJAX operations need the action and post attributes in <form> the way an HTML post submissions does?

I understand how the action and method attributes work when submitting a form, but is it needed in AJAX operations?
Basically looking for the difference between using AJAX to submit a form to a server versus using HTML post.
AJAX doesn't need a form at all, it is a way of sending a request from the browser to the server which can contain any data you want. For instance, you can track where the user moves their mouse, and send this data to your server every few milliseconds.
If you are using it to send the contents of a form, then technically no, you don't need action and method attributes, because you can read the form fields directly, and send them wherever you like. However, it's usually a good idea to have them anyway, if only as a fallback for if the JavaScript goes wrong, or the user has JavaScript switched off.

How to Update Jquery Data Table

I am using Jquery data table plugin. I was able to display it properly with filtering, sorting and Paging.
But, now the problem is i need to filter the data table rows based on dropdown selection made.
but, i do not have any idea how to do this..I am very new to MVC. So, here i need to send that dropdown selected item as parameter to a server side method and call a method and rebind data to the data table.
I am initially binding data to the data table using for loop and iterating over a datatable
Do i need to use Ajax here..if so how to get the new datatable/data to this view and bind to data table?
Please suggest the way to do..
you use the jquery datatable for this
create function and paste jquery datatable code in there
then call this function on dropdown selection change using jquery.
Tips :jquery datatable code available on net find and use it

Kendo dropdownlist in ajax application

I have an ajax application that returns html including a element. I can give it an id and I am trying to grab it to make it into kendo dropdownlist.
But whatever I try putting the code before or after the ajax result I cannot transform my ajax element into a dropdown.
$jq(document).ready(function(){
$jq("#myselect").kendoDropDownList();
});
Any ideas how to se this with ajax generated elements?
Regards
KArel
remove document.ready event and then add this code $jq("#myselect").kendoDropDownList();
in the call back function of your intial ajax call where HTML is returned. if still not working, please create a JSFiddle soluction and post the link here.
Use the success callback of your Ajax request to initialize your 'element'. Also make sure that your 'element' is input or select html element.

Is there a way to combine Server Binding and Ajax Binding to eliminate the extra request made in Ajax Binding on a Kendo grid?

By default the Kendo Grid for ASP.NET MVC will perform server side requests and load the page and grid on a single request. However, when configured for ajax binding the Kendo Grid for ASP.NET MVC will make ajax requests after the page is loaded which requires one extra request (one for the page and one extra for the data used by the grid). Is there a way to combine server binding and ajax binding to eliminate the extra request made in ajax binding alone? All I'm looking is to load the data for the page and grid at the same request (like Server Side Binding) for the first time and use ajax binding for subsequent requests. To disable the initial load on ajax binding we can disable the AutoBind Configuration Option (autoBind:false) of the grid. Now, I need a way to show the data on the grid while the autobind option is disabled. Any idea????
To bind the Grid initially you should either pass your collection to the Grid method.
Html.Kendo().Grid<Customers>(theCollectionOfCustomersWhichWillBeUsedInitially)
//...
Or you could pass it to the BindTo method (which is actually the same ;)
Html.Kendo().Grid<Customers>()
.Name("someName")
.BindTo(sameCollectionasAbove)

MVC3 - repopulate dropdownlist with Ajax after modal form submit

I'm building an MVC3 application and would like to have a form with a dropdown list, and if the option the user requires is not there, then they can click on a link to open a modal popup box, fill a different form out, submit it and close the form, and repopulate the dropdown list which will contain the option they have just added.
I've looked at options of using either jQuery Ajax or MVC Ajax (e.g. Ajax.BeginForm, Ajax.ActionLink). Can anyone recommend the best one to use, and also point me in the direction of a good tutorial? Been having a good look today but can't find anything that really does what I'm looking for.
Thanks
I typically use jQuery in these situations. In this case I would use .ajax() post to perform the form's action. I would then add a handler in the .ajax()'s success event to add my new item to the dropdown using append, example minus all properties except for success handler:
$.ajax({
success: function() {$(myDropDown).append(theNewListItem);}
});
You can generate theNewListItem by having it created and returned from the server in the ajax call, or simly build it using the current form values, assuming the values have been validated.

Resources