removeFilters(filters) : Ext.util.Collection - filter

Can someone please explain to me how can I use removeFilters(filters) method from Ext.util.Collection?
I've seen a similar post here: Remove Individual Filters from Store in Sencha Touch 2.x but it wasn't very helpful to me.
I have a list of contacts and I want to filter it with 2 filters for example and after that to remove only one filter. For now, I have a store that gets the data from a file but I wil make it to read data from a server. Thanks.

No problem.
var oldFilters=[];
var newFilter;
var store = myList.getStore();
oldFilters = store.getFilters();
newFilter = oldFilters[1]; //get the second filter
store.clearFilter();
store.setFilter([newFilter]);
If you want you can keep the store from sorting to speed up things.

Related

Laravel Paginate not working with specific model or table

Paginate not working for specific model. with all Models, paginate is working fine except one specific model. Also tried with query builder.
$doubts = DB::table('users')->paginate(10);
dd($doubts->count());
//output: 10
$doubts = DB::table('doubts')->paginate();
dd($doubts->count());
//output: 0
$doubts = DB::table('doubts')->get();
dd($doubts->count());
//output: 8
Don't know what am I missing here. Please help.
Maybe I think you have to put
How many results you want to show per page
So if you want 8
Then I think it should be something like this
$doubts = DB::table('doubts')->paginate(8);
dd($doubts->count());
And if you are using pages Number under your data then you might need the query builder.
You should pass number argument inside paginate function.
Look at laravel pagination documentation
And make sure that DB::table('doubts')
Is returning collection
I thing you must add parameter in paginate(), to show how much data that show per page. You can read documentation in : https://laravel.com/docs/9.x/pagination#paginating-query-builder-results
https://laravel.com/docs/9.x/pagination#cursor-pagination
because you are not add parameter in paginate, it means not data that show every page.
$doubts = DB::table('doubts')->paginate(10);

I have a problem with the method removeChild

I'm new here on Stackoverflow, started programming in January, small own applications could already be implemented and now I have a problem with JavaScript with the removeChild method, because I don't know how to use this method with other methods and functions can combine or must write.
Thanks in advance
Not really sure what you are trying to do, your question should be a bit more specific.
Just as an example, say you want to remove all items from a list, here's an example of what could be used.
var element = document.getElementById("top");
while (element.firstChild) {
element.removeChild(element.firstChild);
}
If you simply want to delete one child you would need to know the parent's Id, it is done like so...
var d = document.getElementById("top");
var d_nested = document.getElementById("nested");
var throwawayNode = d.removeChild(d_nested);
you can try the W3School documentation if you'd like
https://www.w3schools.com/jsref/met_node_removechild.asp

app scripts data validation from another workbook

I'm trying to validate cells based on a list from a different sheet in a separate workbook. I tested it by copying the desired sheet into the current workbook, to build the code. I changed all the references to reflect the actual source I wanted and everything seemed fine. when I deleted the copy I then had issues as it seems the data validation was still using the copy even though all the references were changed to the original source.
var DbSheet = SpreadsheetApp.openByUrl(ingredientDbBookUrl).getSheetByName(ingredientDbBookName);
function nameValidation(){
var cell = sheet.getRange(3,nameColumn,recipe.getLastRow(),1);
var list = DbSheet.getRange(3,2,ingredientDbSheet.getLastRow());
var helpText = 'helptxt';
var rule = SpreadsheetApp.newDataValidation()
.requireValueInRange(list)
.setAllowInvalid(false)
.setHelpText(helpText)
.build();
cell.setDataValidation(rule);
is it possible to validate cells from a list in a separate workbook? does the fact that I'm using a bounded script matter?
I did it with this:
function validatefromanothersheet() {
const ss=SpreadsheetApp.openById("Another ssid");
const sh=ss.getSheetByName('Sheet1');
const list=sh.getRange(1,1,sh.getLastRow(),1).getValues().flat();
let rule=SpreadsheetApp.newDataValidation()
.requireValueInList(list)
.setAllowInvalid(false)
.build();
SpreadsheetApp.getActiveSheet().getRange(1,1,10,1).setDataValidation(rule);
}
Is it possible to validate cells from a list in a separate workbook?
Yes
Does the fact that I'm using a bounded script matter?
No
Why did the validation have errors?
This is likely because once you have "set" the validation on a cell, it doesn't matter what the code is that was used to generate it.
It is like building something from a plan, and then expecting the building to change because you have changed the plan.
You would need to first clear the rule and then build the rule and apply it again with the new source.
Just probably best to not use requireValueInRange(range) as the ranges may get crossed over. But if you are converting it to values as your code demonstrates said above, then it should be no issue.
Ref
DataValidationBuilder

Get all members from the mailing list using MailChimp API 3.0

http://kb.mailchimp.com/api/resources/lists/members/lists-members-collection
Using this resource we can obtain only first 10 members. How to get all?
The answer is quite simple - use offset and count parameters in URL query:
https://us10.api.mailchimp.com/3.0/lists/b5b5fdc2fa/members?offset=150&count=10
Finally I found PHP API client for MailChimp API v3:
https://github.com/pacely/mailchimp-api-v3
And official docs about pagination.. I missed it before :(
http://kb.mailchimp.com/api/article/api-3-overview
I stumbled on this one while researching a way to get all list members in MC API 3.0 as well. I noticed that there were some comments on the API timing out when trying to get all list members on one page. I also encountered this at first but was able to overcome it by limiting the fields in the result by using the 'fields' param. My code is for a mass deleter so all I really needed was the ID of each member to put together a batch delete request. Here's how my fetch request looks (psuedo-code):
$total_members = $result['total_items'];//get number of members in list via previous request
https://usXX.api.mailchimp.com/3.0/lists/foobarx/members?fields=members.id&count=total_members
This way I'm able to fetch over 15,000 subscribers on one page without error.
offset and count is the official way on the docs, but the problem is that has linear slowdown. It appears to be an n^2 solution, so if you have 20,000 items, you're in trouble. Their docs http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members warn you against using offset.
If you're scenario permits you to use other filters (like since_last_changed), then you can do it quickly. See What is the right syntax for "timeframe" in MailChimp API 3.0 for format for datetime.
Using offset and count parameters are correct as mentioned in some of the other answers, but becomes tedious for large lists.
A more efficient way, is to use a client for the MailChimp API. I used mailchimp3 for python. Using this, it's pretty easy to get all members on your list because it handles the pagination. Here's how you would do it.
from mailchimp3 import MailChimp
client = MailChimp('YOUR_USERNAME', 'YOUR_SECRET_KEY')
client.lists.members.all('YOUR_LIST_ID', get_all=True, fields="members.email_address")
You can do it just with count, making an API call to the list root so in the next API call you include the count parameter and you have all your list members.
I ran into issues with this because I had a moderate list with 2600 members and MailChimp was throwing an error, but it worked with 1500 people.
So for a list bigger than 1500 members I use MailChimp export API bare in mind that this is going to get discontinued but I could not find any other acceptable solutions.
Alternatively for bigger lists (>1500) you could get the total of members and then make multiple api calls to the Member endpoint but I really dislike that :(
If anyone has a better alternative I would be really glad to hear it.
With MailChimp.Net.
Use the offset value.
List<Member> listMembers = new List<Member>();
IMailChimpManager manager = new MailChimpManager(MailChimpApiKey);
bool moreAvailable = true;
int offset = 0;
while (moreAvailable)
{
var listMembers = manager.Members.GetAllAsync(yourListId, new MemberRequest
{
Status = Status.Subscribed,
Limit = 250,
Offset = offset
}).ConfigureAwait(false);
var Allmembers = listMembers.GetAwaiter().GetResult();
foreach(Member member in Allmembers)
{
listMembers.Add(member);
}
if (Allmembers.Count() == 250)
//if the count is < of 250 then it means that there aren't more results
offset += 250;
else
moreAvailable = false;
}

Making improvements to code

I have been working on a magento module for sometime now (not because it is a large module, its my first and I really struggled with it). I now have it working, which I was really pleased with at first, but now I would like to improve it by increasing the reusability of the code.
While making my module I have looked at other modules to learn from them and have seen that many actions are only a line or two and I have tried keeping in with the skinny controller approach but failed, my example is as follows:
I have a function that get a users details that they have inputted into a custom form
protected function _setPostData()
{
$this->_salutation = $this->getRequest()->getPost('salutation');
$this->_f_name = $this->getRequest()->getPost('f_name');
$this->_l_name = $this->getRequest()->getPost('l_name');
$this->_email = $this->getRequest()->getPost('email');
$this->_emailAddressCheck = $this->getRequest()->getPost('emailAddressCheck');
$this->_gender = $this->getRequest()->getPost('gender');
$this->_country = $this->getRequest()->getPost('country');
$this->_pref_lang = $this->getRequest()->getPost('pref_lang');
}
I feel that this is not the correct way to do it and that there is a better way of achieving the same goal, as you can see this function gets the posts data and assigns it to attributes that i've set at the start of the class. I have several other examples that are very similar to the above and if someone could please offer some guidance on this one I am sure I will be able to work out the others
This example is held within the index action, should I put it in a helper as once it created correctly i am sure there will be a few occasions that I will be able to use it again?
you should put all the post data on an array and use it from there
$dataArray=$this->getRequest()->getPost();
$this->_salutation = $dataArray['salutation'];
$this->_f_name = $dataArray['f_name'];
$this->_l_name = $dataArray['l_name'];

Resources