How to turn off "page" event seletively - jqpagination

I am using the jqPagination from Ben Everard. It's a nice plugin and saved me coding pagination logic.
I have a search and a button ,when a user enters a value and clicks the button I do Ajax search and the following to update the paginator:
$('#search-by-quote-id-paginator').jqPagination('option', 'current_page', 1);
$('#search-by-quote-id-paginator').jqPagination('option', 'max_page', totalpages);
(This required because on the screen the paginator may be showing the "page x of xxx". Since the user has launched a new search by entering in the search box and pressed the button. )
However each of those lines triggers a page: event and my page: function gets executed. How can I turn off triggering of the "page:" event selectively , I want it to happen only on the following line:
$('#search-by-quote-id-paginator').jqPagination('option', 'current_page', 1);
so I want to turn it off for the following line
$('#search-by-quote-id-paginator').jqPagination('option', 'max_page', totalpages);
Thanks !
Harinder

This issue has now been fixed in version 1.3 of the plugin.
You can now set multiple options with one call to the option function, this includes the option to not trigger the paged() callback:
$(".pagination").jqPagination("option", {
max_page : 1,
current_page : 50,
trigger : false
});

Thanks for the update.
I have turned off the paged event for the 'max_page' by changing the following line in the function base.setMaxPage = function (max_page) in the jquery.jqpagination.js :
// update the input element
base.updateInput();
was changed to ...
// update the input element
base.updateInput(true);
Thanks !
Harinder

Related

How to show and update current page number in an input box palceholder Using Tabulator

I am trying to show the current page number in an input box as a place holder the issue is I can't figure out how to update the value when users go to another page.
Here is what I tried:
<input id="currentPage"/>
document.getElementById("currentPage").placeholder = tabulator_table.getPage();
Here is the first part of the question
Here is sample
You want to use the pageLoaded callback on the table instance.
When creating the table, you need to add a property for pageLoaded as a function with a parameter for the page number. This callback is triggered each time the page is loaded.
Here is a working example, https://jsfiddle.net/nrayburn/w68d75Lq/1/.
So you would do something like this, where #table is the element id for the table and input is a reference to your input element where you keep the page number value.
new Tabulator('#table', {
...tableOptions,
pageLoaded: (pageNumber) => {
input.value = pageNumber
}
});

Delete a field value based on checkbox-Netsuite

I have a requirement where if the user unchecks the checkbox the vale of certain field should be cleared while he saves it.
To be printed is a checkbox
Check # is field.
If the user unchecks the "To be Printed" checkbox the check # field should be clear while he saves the page.
This should be a user event and will be it be after submit funtion?
How do i achieve this?
Here you have two options to deal with your requirement.
1) You can write a Client script as #John mentioned above on his comment and on field change you can clear out those field values which you don't want to save upon your form submission.
2) Write a before submit function and validate the checkbox field value, if it is unchecked then clear out those fields, which you don't want to save.
I would recommend using user event before submit script to set field value as null, as client script may not fire if data entry point is through csv import, suitescript, etc.
if (nlapiGetFieldValue(TO_BE_SUBMITTED_FIELD_ID) == 'F'){
nlapiSetFieldValue('tranid', null);`
}
If you wish, You may write additional client script to disable/clear the field if value of checkbox is set to false, for better UX.
For sequence number I would say, use the below code (I am assuming sequence numbers are pure numbers)
if (nlapiGetFieldValue(TO_BE_SUBMITTED_FIELD_ID) == 'T'){
//search in descending order (use this code in your same before submit script)
var search = nlapiCreateSearch(RECORD_TYPE, ['mainline', 'is', 'T'], new nlobjSearchColumn('tranid').setSort(true));
var results = search.runSearch();
var records = results.getResults(0, 1);
var nextTranId = praseInt(records[0].getFieldValue('tranid'), 10) + 1;
nlapiSetFieldValue(tranid, nextTranId);
}

beforePageLoad failing when a view column is computed

I've got a view control which opens an xpage. When the xpage opens, the beforePageLoad event fires. It checks to see if there are any attachments in a particular field of the document being opened and if there are, it returns list of the filenames. This was working fine. Then, I was asked to change what's displayed in one of the columns of the view. I added a variable to the view control's data section to access the row. I then added some javascript to the column to display the data differently. That worked and it displayed the data as wanted. However, when I now click on the link to open the xpage, when the beforePageLoad event fires, the code that's there now fails. It fails with this error at the starred line:
Script interpreter error, line=9, col=49: 'closureField' is null at
[/Function_ReturnListOfClosureAttachmentNames.jss].ReturnListOfClosureAttachmentNames(CCEB1351591847CB85257E7C005EF68C)
function ReturnListOfClosureAttachmentNames(ltDoc ){
var closureAttachmentFileNames = "";
var thisLT = ltDoc;
var closureField:NotesRichTextItem = thisLT.getFirstItem("closeAttachments");
*>>> var eos:java.util.Vector = closureField.getEmbeddedObjects();<<<
var eosi:java.util.Iterator = eos.iterator();
while (eosi.hasNext()) {
var eo:NotesEmbeddedObject = eosi.next();
closureAttachmentFileNames = closureAttachmentFileNames +","+eo.getName();
}
return closureAttachmentFileNames;
}
I call this function from the beforePageLoad event and pass it currentDocument.getDocument(). I think I might have lost the document context after changing the column display data from 'view column' to 'computed value' but I'm not sure. Any ideas would be appreciated.
thanks!
Clem
Figured it out: When I assigned a variable to the view, when you click on a linked column in that view, it loads the current ViewEntry into the context and not a current document. So I put the unid of the doc from the selected ViewEntry in an application scope variable and returned it to the Document Id property when I open the xPage. I have to now update all my views but there aren't too many luckily. Thanks for working through this with me!
Clem –

Conditional validation not working for one field

I've 4 fields as shown below:
radioGroup1 is required if comboBox2 value and radioGroup4 & radio1 are blank. The validation message is suppose to go away if only one of 3 radio's is selected
If I select radioGroup1 or radio1 and update page, the validation message does not display.
If I select radioGroup4 and update page, the validation message is still displayed.
Here is a screen shot:
Here is a validation code for radioGroup1:
var comboBox2:com.ibm.xsp.component.xp.XspSelectOneMenu = getComponent("comboBox2");
var radio1:com.ibm.xsp.component.xp.XspInputRadio = getComponent("radio1");
var radioGroup4:com.ibm.xsp.component.xp.XspSelectOneRadio = getComponent("radioGroup4");
var radioGroup3:com.ibm.xsp.component.xp.XspSelectOneRadio = getComponent("radioGroup3");
if(comboBox2.getValue()!==''){
if(radioGroup3.getValue()==null){
if(radioGroup4.getValue()==null && radio1.getValueAsString()==''){
return true;
}else {
return false;
}
}
}
In second image there is a computed field capturing value of radioGroup4.
What am I doing wrong? When page is refreshed, radioGroup4.getValue() works in computed field but not in the validation script for radioGroup3.
When any one of 3 radio control selected, the other two are disabled thru script and it is working without any issue.
Resolved this issue as follows:
radioGroup4 was executing script and doing full update in the onChange event. Changed it to onClick event
It need two clicks in the radioGroup4 and required message for radioGroup3 vanishes.
This is not a perfect solution but I've to leave with it until I found perfect one.

jqgrid - initial filter value not properly set when using searchoptions with dataUrl

I think this is a bug in jqGrid (I'm using version 4.4.0). In my colModel, this works fine:
stype:'select', searchoptions: {sopt: ['eq','ne'], value:"Red:Red;Green:Green;Blue:Blue"}
but this does not:
stype:'select', searchoptions: {sopt: ['eq','ne'], dataUrl:'rest/selectcolors'};
where the dataUrl is returning
<option value='Red'>Red</option><option value='Green'>Green</option><option value='Blue'>Blue</option></select>
The colors show up okay in the combobox with 'Red' as the default value but the filter is not correctly initialized unless the user changes the combobox filter by selecting 'Green' or 'Blue' (and then possibly going back and selecting 'Red'). If the user tries to filter without first changing the combobox value, no matches are found. This problem occurs upon initial use of the filter dialog and after resetting the filter dialog, so it is very confusing to the user.
Does anyone know of a workaround / fix for this?
in first sight your returned dataurl doesn't have
<select>
and it might be a mistake
however, i have this problem too!
but i don't find any solution by search on web.
i resolve this problem temporary by a trick
i add one option with value = -1 and text "Please Select"
then in change event i remove this option
searchoptions: {sopt: ['eq', 'ne'], dataUrl:'yoururl',
dataEvents:[{ type: 'change',
fn: function(e)
{
$('td.data').find('option[value=-1]').remove();
}
}]},
but the problem still exist.. if user doesn't change combobox and select "Please Select" option, he will see an error.
i use the folowing code in my php url
echo "<select>";
echo "<option value='-1'>please select</option>";
while($row = pg_fetch_assoc($res))
{
echo "<option value='".$row['cid']."' >".$row['cname']."</option>";
}
echo"</select>";
you can use an style like this and remove it after change for select element
style='font-style:italic; color:gray; width:100px' data-native-menu='false'

Resources