Get element other web page using Javascript/jQuery - javascript

I need to update 2 tables. Each table on an other web page. I'm using javascript to delete the object from the database and to delete the row from the 2 tables. But javascript can only delete the row from the table that is from that document.
Simply said: I can't get the table element from the other web page. After searching a while i found that i have to do it with jQuery/Ajax but i can't fix it. Here's part op my code:
function deleteItem(action,cdplayer,index){
//using ajax to delete the object from database
var information = "action=" + encodeURIComponent(action) + "&cdplayer=" + encodeURIComponent(cdplayer);
xHRObject.open("POST", "StockServlet", true);
xHRObject.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
xHRObject.send(information);
//deleting the row from the table of that document
var table = document.getElementById("tableAdmin");
table.deleteRow(index);
//here i have to delete the table from the other document
}

Related

PreSearch lookup entity grid in PowerAppsPortal JQuery

I have DataVerse form in PowerAppsPortals.
One of the field is LookUp for another Dataverse table.
What I need is to prefilter entity-grid in Lookup based on variable which I get from one of the form fields.
var Pesel is the variable that I need to filter with.
The method tr.remove() works (tr.hide() also works) but because my entity grid is paginated when it found value for example on second page of grid it doesn't automatically move found record to the first page - user has to manually move to exact page on which jquery found row.
My lookup grid contatins 6000 records - after change of parameter PageSize to 6000 it takes forever to load grid and prefilter it.
I beg you to help me, I think I've searched whole internet and can't find solution.
var Pesel - it's the value that I get from form field and want to search for it in grid view.
PeselGrid - it's the value that I've picked up from column in grid view.
What I need is to simply prefilter this grid view with jQuery after user opens it - he fills the correct fields in main form and jQuery prefilters grid view to show for him only found rows (something like using the search field in grid view)
$(document).ready(function(){
$(".entity-grid").on("loaded", function () {
var Pesel = $("#cr94f_pesel").val();
var tBody = $(this).find("tbody");
$(".entity-grid").find("table tbody > tr").each(function () {
var tr = $(this);
var PeselGrid = $(tr).find('td[data-attribute="cr94f_pesel"]').attr("data-value");
if (PeselGrid != Pesel) {
tr.remove();
}
});
I think that I've searched whole internet for the solution

Fetch the contents of a table row using javascript when a link is clicked

I have a dynamic table and in one of the attributes of that table I have edit link, I want to fetch the data adjacent to that link if that link is clicked.
For example if I click Edit on line number 2, I should be able to retrieve Demo User, demouser, demo#demo.com and User using javascript.
The key is to access the row and then find elements inside that row:
$('.your-link').click(function () {
const row = $(this).closest('tr');
const whatever = row.find('.whatever').text();
})

Appending row with checkbox in google scripts

Im writing a small google script for an excel sheet which appends a row on a POST request: depending on the POST parameters I either append the row to the end, or I insert it in between rows.
One of the columns of the is actually a boolean that Im trying to represent as a checkbox.
The problem is when I try to append a row
sheet.appendRow([e.parameter.parameter1, e.parameter.parameter2, "FALSE"]);
It simply writes false in that column.
On the other hand when I insert a row in between other rows:
sheet.insertRows(position);
sheet.getRange("A" + (position)).setValue(e.parameter.parameter1);
sheet.getRange("B" + (position)).setValue(e.parameter.parameter2);
sheet.getRange("C" + (position)).setValue("FALSE");
The checkbox column (takes the format from the surrounding rows?) and becomes a checkbox.
Is there a simple solution to append a row with a column as a checkbox?
Thank you.
You need to create a checkbox first with data validation
Sample:
var checkbox = SpreadsheetApp.newDataValidation().requireCheckbox().build();
sheet.getRange("C" + (position)).setDataValidation(checkbox).setValue("FALSE");

Deleting a Row from Datatable in Jquery

I used Backbone collection to create a table and applied jquery data-table for pagination. I have an icon to delete the row. When clicked it is deleting from collection but deleted row is still present in data table.
More information:
I have the collection with person details (firstname:Tony). And this data will sit in template "{{firstname}}". In that way I'm setting the entire row in template. Suppose my collection is named as "addedGridRowCollection" to which each individual person detail is set to model(ex:addvisModel) and in turn model is set to collection. Hence the code is as ---
var addedVisitorGridView = new AddedVisitorGridView({
collection: addedGridRowCollection
});
newVisitorLayoutView.gridRegion.show(addedVisitorGridView);
addedVisBasicModel.set("firstname", "Tony"); addedGridRowCollection.add(addedVisBasicModel);
applyDataTable(); // applying jquery data table
$(addedVisitorGridView.el).show();
Now in delete trigger: when I clicked on Delete button,The following is the code I am using:
var indx= model.get('index');
var visModel = addedGridRowCollection.findWhere({index: indx});
addedGridRowCollection.remove(visModel);
here it removes from collection but not from the data-table (Jquery).

How to pass selected sql row id from dynamic query results to javascript?

i have a php page with a table populating dynamic sql query results. if i click on one row, how am I going to pass the row id of that item by javascript?
thanks.
Using jQuery:
$('#table-id tr').click(function() {
var id = $(this).attr('id');
});

Categories