I have grid and want to apply default sorting on it, I am getting parameters from an API. My flow is as below.
Store.sort(sorters), where this code do load operation and after refreshing grid, It fires an event sortchange event on first load. How can i prevent it?
Update: I tried sortOnLoad:false. But, it is not working.
in sortchange event there is one parameter called column
so,when it will called just check column.hasFocus. if it will true that means user sort from grid header.
and if it return false that means it's called by loading or removing data.
Hope, this information will help you..:)
Related
I have several dynamic actions that are fired with change event on page load. It seems like all of them are fired at same time. When that happens it adds filter to the interactive grid. Now, the problem is some of the filters are duplicated. How can I solve this problem?
I mean when page loads, it changes bunch of things in the form (like checkboxes and values of textfield), that fires the dynamic action, which then calls addFilter function like this
function newFilter(){
var vals = apex.item('P12_VALUE').getValue();
if(!(vals.includes('DI'))){
deleteExistingFilters('emp', 'IS_ON');
}
if(vals.includes('DI')){
if(!filterAlreadyExist('emp', 'IS_ON')){
addFilter('emp', 'IS_ON','Y','EQ');
}
}
}
Create only one dynamic action that fires on page load, but let it execute several ("true"?) actions, i.e. every action would be one or none of those "several" dynamic actions you have now. "None" means that you'd exclude it if it is already set.
I am using jquery.dataTables.yadcf.js and //cdn.datatables.net/1.10.6/js/jquery.dataTables.js with sAjaxSource
I'm trying to use external filters that triggers several columns to a pre-selected filter at once. So you click a button and there, three columns are picked out so you don't have to go in each drop down.
But the way I'm doing it seems wrong, because I'm seeing two JSON requests instead of one every time they're triggered.
All I have in my script is
function doTrigger(){
yadcf.exFilterColumn(oTable, [[0,"zero"],[1,"one"]]);
$("#yadcf-filter--oTable-" + 1).val("one");
oTable.fnDraw();
}
Your code should look like this: I haveadded third argument true, its undocumented, but needed when calling the exFilterColumn after table finished loading
function doTrigger(){
yadcf.exFilterColumn(oTable, [[0,"zero"],[1,"one"]], true);
}
The rest of your code is not needed at all...
I used twitter bootstrap for my system. For displaying all of my data from the database, I used dataTables for it. I've added a new column as "Action" that contains 2 buttons, edit and delete. But when the record reaches more than 10 for the first pagination, all of the rows which contains my buttons on the second pagination and next pagination does not execute my jQuery code that handles the delete and edit function.
Can anyone help why is this happening? What are the possible solution for this problem? Really need it. Thanks.
Supposing you bind your delete and edit function on $(document).ready() then the explanation is simple: at that point only the first page is available in the DOM and only the buttons on the first page will bind.
What you need to do is to rebind your events every time you change the page. For this, you need to call your binding jQuery code (let's say you have a method named BindEvents() that does that) on the fnDrawCallback event of your DataTable:
var dataTable = $("#YourTable").dataTable({
// additional data table params,
"fnDrawCallback": function () {
BindEvents();
};
See http://legacy.datatables.net/usage/callbacks#fnDrawCallback for more details.
im setting both values of my range-slider with the following line: $('...').slider( 'values', [ 0, 10000 ] ); Now i have the problem, that this line triggers two times the change( event, ui )-event. Is there a workaround to only trigger it one time? Or is there an other event that i could use / create to get the problem solved?
I just want to avoid sending two times an ajax-request of a huge amount of data
thanks for your replies!
Peter
An article here for you: Setting slider value without triggering change event
If you apply something like this when you're setting values in script, you could call your ajax request outside of the change handler and after you set your slider values.
I have Grid with a subgrid using subGridRowExpanded.
And I want to dynamically expand some rows of the grid so I wrote following
in GridComplete Event of First Grid.
ids is array of row ids of my Grid
for(int i =0; i< ids.length; i++) {
//Checking with condition
$("#myGridName").expandSubGridRow(ids[i]);
}
I also tried with following code, But for some reason checkboxes in GridComplete of second level, is added only for last expanded row.
$("#myGridName").expandSubGridRow(ids[0]);
$("#myGridName").expandSubGridRow(ids[1]);
Above code expands appropriate rows. But,
In GridComplete event of Subgrid, I've check boxes in each row.
So, Here I need to check some of the Chekc boxes.
But the Problem is,
The subgrid_row_id is getting wrong
i.e. ID of last subgrid to be expanded is assigned in SubGridRowExpanded of Parent Grid.
Note : I manually adding checkboxes to each row in subgrid
Thanks in Advance.
If I understand you correct you have very close problem as discussed in the answer. What you try to do seems the same what expandOnLoad: true property of the subGridOptions option should do. Like I described in the answer jqGrid don't support queuing of Ajax requests. If you execute
$("#myGridName").expandSubGridRow(ids[0]);
with remote datatype or subgridtype ('json' or 'xml') the Ajax request will be sent to the server. Till we receive the corresponding response from the server the internal property
$("#myGridName")[0].grid.hDiv.loading
will be set to true and all other Ajax requests for example from $("#myGridName").expandSubGridRow(ids[1]) will be just skipped (ignored).
The same problem (bug) exist in the current implementation of expandOnLoad: true. If you open in the official jqGrid demo the "Hierarchy (4.0) new" tree node and then look at the demo "Expand all Rows on load" you will see that not all rows are correctly expanded as promised (you have to scroll the grid to see all subgrids).
I think that to implement expanding of subgrids on load correctly you should do about the following
You should examine the list of collapsed subgrids (the corresponding row has class "sgcollapsed") and expand only the first found subgrid.
The expanding of the next subgrid should be done only after the response from the server will be received and processed.
I can recommend you to use success callback function of ajaxSubgridOptions jqGrid options because there are no loadComplete event after loading the subgrid. The current implementation of the Ajax request in subgrid uses complete callback function of jQuery.ajax (see here) which will be called before success callback. So you can define your success callback as the method of the ajaxSubgridOptions option of jqGrid. Inside of the success callback you can call $("#myGridName").expandSubGridRow(ids[i]) for the next node (if any still not expanded). In the way you can open all subgrids.
To enumerate subgrids more effectively the answer could be helpful for you.