Get value from select record in store - extjs

Hello I'm have store and I want get value in field ID from this store.
Ext.ComponentQuery.query('price gridpicker[name=price]')[0].store.getAt(0).data.id;
But this output only ID from first record in store, and when select other record I will still get ID from first record, help me thanks

If you want to get the selected record then you need to query the grid, not the store. The store just contains the data, it doesn't know what's going on on the screen.
Ext.ComponentQuery.query('price gridpicker[name=price]')[0].getGrid().getSelectionModel().getSelection()[0].get('id');

The correct call is:
...getAt(0).get('id);
or, if you want all record's data then
...getAt(0).getData();
Of course, you can get also other values but you need to know which record is selected by the gridpicker.

Related

Query of Arrays in Salesforce

I need to do 1 of two things (I believe):
1- Get a Custom Object ID so I can query it directly
2- Get a list of values of a specific field within the Object entries.
Ultimate End goal:
Add and modify rows in my custom object via external API. However to do this I need to check and make sure my new entry/row does not already exist.
What I have:
I have a custom object (called Customer_Arrays__c). It is a table that I can add new rows to (I will call entrys). Each entry has 6 or 7 fields. 1 of these fields is called (external_ID__c). This is the field I utilize to match to new incoming data to see if the entry already exists, or if it needs to add a new row to my table. This Customer_Arrays__c is a child to my opportunity I believe – it is part of every opportunity and each line item I add has a field defaulted to the opportunity.
Help I need:
1- How do I query the value of my Cutomer_Arrays__c based upon an opportunity ID?
2- How do I query a list of values in my (external_ID__c) based upon an opportunity ID?
Thanks for your help! I have read half a dozen+ posts on similar topics and am missing something. Examples of some Past try's that failed:
Select external_ID__c,FROM Custom_Arrays__c WHERE Opportunity='00...'
Select Id (Select ID, Custom_Arrays__c from Custom_Arrays__c) from Opportunity where id ='00...'
List FROM Custom_Arrays__c WHERE Opportunity='00...'
Select Id, external_ID__c, (Select external_ID__c FROM Custom_Arrays__c) WHERE Opportunity__c='00...'
Thanks again!
Only you know how did you name the lookup field (foreign key) from arrays to Opportunity. You'll need to check in setup, next to where external_ID__c is. Since it's a custom field (gets __c at the end), my guess is you went with default.
Try
SELECT Id, Name, External_Id__c
FROM Customer_Arrays__c
WHERE Opportunity__c = '006...'
Thank you eyescream, that got me almost all the way there. Turns out I also needed a __r for the parent child relationship.
Here is a snip out of my final code that works - I think it covers everything:
SELECT Field1__c, Opportunity__r.Id, Opportunity__r.Opportunity__c,
FROM Customer_Arrays__c
WHERE Opportunity__r.Id = '006...'.
Thank you so very much!!!

Laravel show records as flat array or single record

I have 2 column in my table setting
with the following values
KEY VALUE
company ABC
phone 14344
address Somerset City
I need to display this like a single record or a flatten
array in the view/blade page
something like
{{$sett->company}}
{{$sett->phone}}
or an array with lookup
{{$myarray('company')}}
{{$myarray('phone')}}
The idea is if I add another settings like contact us email address
for my website I don't want to add another column.
I know this is achievable in controller by creating different variable
and executing different query but I'm kind of looking for some options here.
Thanks for the help really appreciated.
You can use $settings->pluck('value', 'key') to get your result. Read more here: https://laravel.com/docs/5.4/collections#method-pluck

How to Get Last Update id in Cake PHP

I want to update set of Records, so iam using following code and then i need update the updated row id to another table, so i want to Last Updated Row ID
$this->mymodel->updateAll(array('field1'=>0),array('field5'=>0));
In order to get the ID of the last row, you can simply use this getID function:
$this->(Model Name)->getID()
Check out the following reference for more relevant functions: http://book.cakephp.org/2.0/en/models/additional-methods-and-properties.html
Peace! xD :)

Table with dummy row (ID 0) and auto increment index

Is it legal/okay to create a row with ID '0' and AFTER that set auto increment of that ID column to (1, 1)?
Why do I ask this?
I have a table Products with columns ID and Name. I want to show all Products inside my application in a ComboBox. Users can select a product but the default entry should not be 'Product 1' but something like '(Nothing selected)'. Is it okay to create a 'dummy row' with 'ID = 0' and Name = '(Nothing selected)' in database so the application will automatically display it as default selected item?
I think the better solution is to programmatically add a please select option and validate against it, assuming you don't really want users to have this selected? I guess in theory what you've proposed should be OK though? You'd have to be careful retrieving the values in order of their Id though, if you ordered them by name you'd have to ensure you pulled Id = 0 first then ordered the rest which feels like more work then programmatically adding the option where needed to me.
If your users can have nothing selected then programmatically add the nothing selected option and handle saving no value if it is selected. Otherwise you're saving data that represents no data really which could be deemed a waste of memory.

Adding a record to the store in specific place

Is there a way to add a record to the store after the specific record not using addSorted?
Check Ext.data.Store.insert(index) which allows you to insert a record at a specified index. Only thing you need is the index of the record you want to insert it after, thats what you have Ext.data.Store.find() for
http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.Store
More specific way to add new element(s) in store at first place like...
Ext.data.Store.insert(0, [{id: 0, name: '(un-assigned)'}]);

Resources