Access a localStorage data inside Laravel 4.2 controller - javascript

In my view I have this Javascript code that gets the data from a selected row from a table, puts it in a localStorage then display the data on the page.
For visualization here is what it looks like
By default, the "Assign Grade" section is hidden and it will be only show when the user clicks the edit button on the table rows. The data from the row would then be showed on the left side of the "Assign Grade" panel. On the background what I did was when the user clicked edit I stored the Record ID inside a localstorge
My Javascript code:
$("#gPanel").slideDown(350);
var index = x.rowIndex;
var tbl = document.getElementById("detailTable");
var ri = tbl.rows[index].cells[0].innerHTML;
var sy = tbl.rows[index].cells[1].innerHTML;
var sq = tbl.rows[index].cells[2].innerHTML;
var si = tbl.rows[index].cells[3].innerHTML;
var sn = tbl.rows[index].cells[4].innerHTML;
localStorage.recid = ri;
//more
document.getElementById("rid").innerHTML = ri;
//more
Because I need that Record ID when the "record grade" button on the "Assign Grade" panel is clicked.
Is there a way to access localStorage inside Laravel 4.2 controller? Or is there a better way to do it?

Related

send the value of the field from an interactive grid to another page and store it in an item with Javascript and Oracle Apex

Good evening, I currently save the value of a field of the grid in an item (P5_VALUE),send it to another page (page 6) and store it in an item (P6_VALUE) through a button
Action: Redirect to Page in this application.
Target: Page in this application , Page: 6, set Items: NAME: P5_VALUE, VALUE: P6_VALUE, Action: Reset Pagination. This is the url that is generated: http://ip:port/ords/app/system/page?p5_value=61&clear=RP&session=12518184703789
But now I want to do the same with APEX$ROW_SELECTOR. With this code I have been able to add an action to the grid and get the value of the field but I do not know how to send it to the other page and assign the value to the other item
var view = apex.region("ig-emp").widget().interactiveGrid("getViews", "grid"),
menu$ = view.rowActionMenu$;
menu$.menu("option").items.push({
type:"action",
label:"Get Emp No",
icon: "fa fa-close",
action: function(menu, element) {
var record = view.getContextRecord( element )[0];
var val1 = view.model.getValue(record, "EMPNO");
}
});
Por favor su ayuda, gracias
Use the below approach to achieve this:
Let me start by adding some more lines to your code.
var view = apex.region("ig-emp").widget().interactiveGrid("getViews", "grid"),
menu$ = view.rowActionMenu$;
menu$.menu("option").items.push({
type:"action",
label:"Get Emp No",
icon: "fa fa-close",
action: function(menu, element) {
var record = view.getContextRecord( element )[0];
var val1 = view.model.getValue(record, "EMPNO");
apex.page.submit({
request:"NAVIGATE",
set:{"P1_EMPNO":val1},
showWait: true
});
}
});
Note: in the above code replace P1_EMPNO with your page item name.'
Create a Branch -> Type: Page or URL(Redirect).
Select the page number to redirect and set the value of the current page item to the new page item. Refer below screen shot for example.
In the Server-side condition, select the Type as Request = Value and provide the value as NAVIGATE. Refer below screen shot.

Show data from database into label

I have database like this:
How I can set all row into label or hiddenfield, ?
if I use code like this, i just get last data from row database.
While (result.Read())
Label1.Text = result.Item("StartDateBlock")
Label2.Text = result.Item("StartDateBlock")
Label3.Text = result.Item("StartDateBlock")
Label4.Text = result.Item("StartDateBlock")
End While
please don't suggest me to use repeater

PHP-CodeIgniter: How to get the corresponding html table row values to be deleted by Javascript

In my codeigniter project i'm using a Table in which it is dynamically generated by Ajax. on the each row there is a button to Delete the corresponding row from Html Table and Mysql table too.
i tried it already. and i get the code to remove Html table row , and it follows
$(document).on('click', '#deleteRow', function() {
$(this).parent().parent().remove();
});
and it worked. but i want to delete that corresponding row from Mysql too. so first of all , it needs to be pass the corresponding row informations from javascript. then pass this to the Controller via URL.?
window.location.href = "<?php echo base_url("settings/remove_company"); ?>?id="+current;
How i get corresponding row informations such as company_id, lic_id (field names of html table).?
any help would be greatly appreciated .
Add attributes to the <tr>
<tr data-companyId="<?php echo $companyId;?>" data-licId="<?php echo $licId;?>">
In your jQuery, get those attributes on click of delete link:
$(document).on('click', '#deleteRow', function() {
var companyId = $(this).parent().parent().attr('data-companyId');
var licId = $(this).parent().parent().attr('data-licId');
$(this).parent().parent().remove();
});
Even, you can do object caching (using variable instead of object to improve performance.
$(document).on('click', '#deleteRow', function() {
var obj = $(this).parent().parent();
var companyId = obj.attr('data-companyId');
var licId = obj.attr('data-licId');
obj.remove();
});

chap links library - network- how to get table row id

I'm using chap links library https://github.com/almende/chap-links-library/tree/master/js/src/network for drawing an area of objects.
I want to be able to use the id that I have set to an object upon click, I have this code
function onselect() {
var sel = network.getSelection();
console.log("selected "+sel[0].row);
}
It works fine, only it retrieves the row number from the dynamically created table. I want to retrieve a value from that row (an object id that I set) but I don't know how to access it.
I have tired things like
sel[0].row.id
sel[0].row.getId()
sel[0].row[0]
But I don't know how they structure the data in their thing...
Anyonw run into this before and solved it?
This is the way I set the data
nodesTable.addRow([45, "myObjectName", "image", "images/container_icons/icon.png"]);
For my app I solved it by creating a parallel array...
//rendera objekt
window.clickHelper = []; //keep track of container id in conjunction with hierarchy-canvas-object's id
var i = 0; //counter for above
Populating it upon every node creation...
nodesTable.addRow([{{ c.id }}, "{{ c.name }}", "image", "{{ asset('images/container_icons/'~c.icon~'.png') }}"]);
clickHelper[i]={{c.id}};
i++;
Then calling in data from that array on my onSelect event...
function onselect() {
//get selected node from network
var sel = network.getSelection();
sel = sel[0].row;
//get path base structure
var path = '{{ path('editGroup') }}';
//fix path with the DB id of the clicked object
path = path+clickHelper[sel];
window.location.href = path;
}
The double {{ }} are TWIG templating for those unfamiliar with that. Mixed javascript and TWIG ServerSide code here, sorry.

Creating multiple related objects from execute jscript list button

I'm trying to create multiple records of an object called Guarantor__c, a child of Opportunity and Contact, on button click. All of the Guarantor records should relate to the Opportunity on the page where the button is. The records are all of the Contacts of the Opportunity's Account with the Guarantor record type. The SOQL below is pretty straightforward. This runs without an error, but doesn't enter any records. Any ideas?
{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')}
var url = parent.location.href;
var updateRecords = [];
var principalContacts = sforce.connection.query("Select Id From Contact where AccountId ='{!Account.Id}' and RecordTypeId ='012A0000000nr4BIAQ'");
var principalContactsArray = principalContacts.getArray("records");
if (principalContactsArray.length < 1){
alert("There are no guarantors for this opportunity. Go back to the Account and enter the guarantors.")
}else{
for (eachPrincipalContact in principalContactsArray){
var newGuarantor = new sforce.SObject("Guarantor__c");
newGuarantor.COntact__ = eachPrincipalContact;
newGuarantor.Opportunity__c ="{!Opportunity.Id}";
updateRecords.push(newGuarantor);
sforce.connection.create(updateRecords);
}
}
sforce.connection.create(updateRecords);
should be placed outside of the for loop. like
for (eachPrincipalContact in principalContactsArray){
var newGuarantor = new sforce.SObject("Guarantor__c");
newGuarantor.COntact__ = eachPrincipalContact;
newGuarantor.Opportunity__c ="{!Opportunity.Id}";
updateRecords.push(newGuarantor);
}
sforce.connection.create(updateRecords);

Categories