Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ({
- doinit: function (component, event, helper) {
- component.set('v.columns', [
- { label: 'Name', fieldName: 'Name', type: 'text' },
- { label: 'SKU', fieldName: 'ccrz__SKU__c', type: 'text' },
- ]);
- var action = component.get('c.getAllProducts');
- action.setCallback(this , function(response){
- var state = response.getState();
- if(state === 'SUCCESS' || stare === 'DRAFT')
- {
- var responsevalue = response.getReturnValue();
- component.set('v.data', responsevalue);
- }
- }
- },
- });
- ({
- doinit: function(component, event, helper) {
- // alert('doinit'); // to check if doinit is working or not : seems it works but i couldn't seet the preview !!
- component.set('v.columns', [
- {label: 'Product Name', fieldName: 'Name', type: 'text'},
- {label: 'SKU', fieldName: 'ccrz__SKU__c', type: 'text'}
- ]);
- var action = component.get("c.fetchAllProducts"); // this wil get the method getAllProducts form the controller(apex class:TKMB2B_Custom_CC_Spec_Product_Selection).
- action.setCallback(this, function(response){
- var state = response.getState();
- //alert(state); // to check for the State to work !
- if(state == "SUCCESS")
- {
- var responsevalue = response.getReturnValue();
- component.set("v.data", responsevalue);
- }
- });
- $A.enqueueAction(action);
- },
- doselectproduct : function(component , event, helper) // this will give us the functionality to select the products individually
- {
- // alert('record element selected');
- var selectedProduct = event.getParam('selectedRows');
- component.set("v.clearBtn",selectedProduct );
- console.log('selectedProduct', selectedProduct);
- },
- handleClick : function(component , event , helper)
- {
- console.log(JSON.parse(JSON.stringify(component.find('productTable').getSelectedRows())));
- console.log(component.get("v.recordId"));
- var action = component.get("c.updateSpec");
- action.setParams({savedProducts : JSON.parse(JSON.stringify(component.find('productTable').getSelectedRows())), specId : component.get("v.recordId")});
- action.setCallback(this, $A.getCallback(function (response) {
- var state = response.getState();
- console.log('response'+ response.getReturnValue());
- var res = response.getReturnValue();
- if (state === "SUCCESS")
- {
- $A.get("e.force:closeQuickAction").fire();
- }
- }));
- $A.enqueueAction(action);
- },
- clearClick : function(component , event , helper)
- {
- var selectedProduct = component.get("v.clearBtn");
- // var clearProduct = event.set("v.selectedProduct", []);
- debugger;
- for(var i in selectedProduct ){
- debugger;
- var space =selectedProduct[i];
- $("#"+space.Id).prop('checked', false);
- alert('eachloop');
- }
- console.log('clearProduct',clearProduct );
- },
- searchKeyChange: function(component, event, handler) {
- var searchKey = component.find("searchKey").get("v.value");
- console.log('searchKey:::::'+searchKey);
- var action = component.get("c.findByName");
- action.setParams({
- "searchKey": searchKey
- });
- action.setCallback(this, function(a) {
- component.set("v.productTable", a.getReturnValue());
- });
- $A.enqueueAction(action);
- } ,
- Search: function(component, event, helper) {
- var searchField = component.find('searchField');
- var isValueMissing = searchField.get('v.validity').valueMissing;
- // if value is missing show error message and focus on field
- if(isValueMissing) {
- searchField.showHelpMessageIfInvalid();
- searchField.focus();
- }else{
- // else call helper function
- helper.SearchHelper(component, event);
- }
- },
- /*searchTable : function(component,event,helper) {
- var allRecords = component.get("v.productTable");
- alert('searchME');
- var searchFilter = event.getSource().get("v.value").toUpperCase();
- var tempArray = [];
- var i;
- for(i=0; i < allRecords.length; i++){
- if((allRecords[i].Name && allRecords[i].Name.toUpperCase().indexOf(searchFilter) != -1) ||
- (allRecords[i].ccrz__SKU__c && allRecords[i].ccrz__SKU__c.toUpperCase().indexOf(searchFilter) != -1 ))
- {
- tempArray.push(allRecords[i]);
- }
- }
- component.set("v.filteredData",tempArray);
- },
- handleKeyUp: function (component, event) {
- var isEnterKey = event.keyCode === 13;
- var queryTerm = cmp.find('enter-search').get('v.value');
- if (isEnterKey) {
- component.set('v.issearching', true);
- setTimeout(function() {
- alert('Searched for "' + queryTerm + '"!');
- component.set('v.issearching', false);
- }, 2000);
- }
- }
- */
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement