Populate tabular report (multiple records) with particular values - javascript

I have a tabular report that allows the user to enter a reference number (text item) as well as a comment textarea item.
The report can vary in amount of records displayed, but for this example, let's say I have 10 records in the report.
What I am after is to create two new fields identifying both comment and reference no field - let the user type info in these two fields and then have a "Populate All" button that will go through each record in the report and assign the reference number value and comment value to each of the 10 records.

It's not completely clear what you're trying to do here. Do you have a regular HTML form laid out in a table, and then the last two table cells on each row have an input/text area element in them? If so, I would think the easiest way to go about it would be to assign a common class to the input elements in each column, such as 'refno' and 'comment' then have some code like this in the 'PopulateAll' button onclick event:
$(".refno").each(function() {this.value = $($("#refglobal").value)});
This assumes your field for adding the reference number to all has an id of refglobal and that you're using jQuery (though other libraries will allow similar syntax, and coding it out longhand wouldn't be too much effort in this case).

Related

How to get button to act as column search filter within ag-grid and search for a set list of items?

SUMMARY: I have a column for ids within an ag-grid table. How can I get a button-click to only display some of the rows (for which I have a list of ids), while not re-writing the whole table?
BACKGROUND: I am using the community version of ag-grid and am using it with Javascript. I have a column with the id numbers in it. When I click a button (or something else eventually, but start with a button for simplicity), is it possible for it to act as a filter within the table, and hence could be undone by clicking another button to clear the filter?
In case that wasn't cleaar, I am looking to do:
1. Click button1
2. Display certain rows within a table whose id numbers are in my list variable
3. Have this button1's action act as a filter that can be undone by a button2 (which could be programmed perhaps like a clear filter button)
Is this possible to do with a quickfilter? Otherwise, if this isn't possible, how could I do this when over-writing the table, whilst still having the option to 'instantly' revert back to the original table
(I don't think I need to add code as I am unsure of how to build in this functionality)
Thanks in advance.

Getting row data on Interactive Report

Morning,
I'm currently using an Interactive Report on APEX that contains several columns, some of them being checkboxes that represent if a certain number is present in the table that is being used to fill the report.
For example, row 1 has a telephone number "99091021", row 2 a provider, and the following 5 rows are checkboxes that should represent branches in certain areas. If a checkbox is clicked, it means that this number is present in that area.
Now, I'd like to create a dynamic action that inserts that number into that table when I click the checkbox (and it becomes checked), and a delete for when it's also clicked (and becomes unchecked). Problem is, I don't know how to access the rest of the data in the row of the IR to use as a comparison for the delete and insert statements.
Say I try to click the Checkbox 3 on the row where the telephone number is "99091021". A dynamic function would get the data row, then a true action would compare the necessary data to perform either an insert or delete, depending on the state of the checkbox. That's the plan.
I've done something similar before, using localStorage, but it didn't quite work, because before I used it on an interactive grid. Is there a similar function for interactive reports?
Also, is there a way to check if a checkbox is checked or unchecked in a PL/SQL Code?
Here's the solution I found:
I had a select that got the necessary data for the Interactive Report, but because I kept getting an error of temporary data table being exceeded and always breaking the server, I had to change the checkbox query to something like this:
apex_item.checkbox (1, '1_'||a.pk, case when max(decode(b.nr,1,1,null)) is null then '' else 'CHECKED' end) as checkbox1
The '1_' part represents me selecting the first checkbox. With the value still there as the selection, I was able to do the following:
$s("P165_GET_PK",this.triggeringElement.value)
The result would basically be "1_PK_number". With this function I was able to get the value (a.pk) hidden in the checkbox to an Apex item, and then continue using it for my insert and delete statements. It's just a matter of separating the value in it with substring functions and so on.
Now I can delete or insert new data inside that table with a simple click.
I hope it helps in case someone tries doing something similar.

Storing post display order in database

I am developing a web application which will have images displayed in a slider. It is important that I am able to modify the order that they are displayed in.
Currently, I have a column in the table of images called 'order', which must be set to ensure the ordering works correctly, but changing it requires changing every other, too, which becomes tricky when dealing with hundreds of records.
This table, as well as queries for modifying it, are in development, so it's completely fine to change the way I do this.
My questions are:
When I'm inserting a new row, how can I make sure it appears at the end of the list? Auto-Increment in SQL tends to leave gaps if you delete entries from the table. How do I make sure that the row is assigned an order 1 greater than the highest order in the table?
How do I reorder the table? Imagine that I use a drag and drop interface (or similar) to reorder one image, bringing it to the top, or a different part of the list. If I do that, I need to reset the numbering of every item, which is, again, inefficient when dealing with hundreds of rows.
How do I prevent two rows from having the same order at any given time? The UNIQUE flag on the column? Presumably if I set that flag, changing the order from, say, 8 in one row opens up another to use that number. Right?
Thank you for your time, and I hope this isn't too vague a question to be easily answered!
Query the table you are about to insert into to find the MAX id in the table. Then on your insert just do this +1.
When re-ordering, say you want to set image order 6 to order 3. You will want to update all rows from order 3 and onwards to order+1 then set the image to order 3.
UPDATE table SET id = id+1 WHERE id IN (SELECT * FROM table where id >= 3)
If you are using unique on the order column to re-order you will have to update the current value to a temp value such as 99999, then use method in 2. However method 2 should keep this table from receiving any duplicated values.
sidenote
You could on delete of a picture re-evaluate the ids to keep no gaps
UPDATE table SET id = id-1 WHERE id IN (SELECT * from TABLE WHERE id > 3)
Where 3 is the deleted id
It will be in the end of the list. Just use auto increment feature and do not set ID manually (like lastID + 1) and you'll never have described problem.
You can allow user to change order of the list and then just update all order cells (for each member of the list). Or you can use Ajax and exchange order value for two members every time user drag-and-drops.
Use one of approaches described in 2 and you'll never have this problem.

Jqxdatatable : keep or recover the original names of an HTML table of inputs

I'm new with jqwidgets
I have an html table in a form and the cells of this table are of inputs type
the html is constructed in Java via a JSP
These inputs in the table are submitted by this form when a button is pressed
(all fields are submitted with a specific name)
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxdatatable/index.htm
I am using jqxDataTable plugin to easily replace and customize this HTML Table already constructed on my page
and it works well, the right value is in the right cell
but i lost the name of the input
jqxDataTable transforms the inputs in the cell in a simple div
and consequently, removes the name of this input, and it is a problem for the submission...
i use a cellsrendrer,
so i can put a new input in the cells of my table
but i need to recover the old name and the old id of the input (in the previous HTML table)
in order to associate to the new input in the new table (Jqx) and to be able to submit it with the right name
Is it possible to do this ?
Your help is much appreciated. Thanks.
I finally find a way to answer to this problem
i use jqxgrid instead of jqxdatatable
and i follow this demo example :
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/index.htm#demos/jqxgrid/loadfromtable.htm
so I create an array of row-objects with the input names
during the loop
as it is done in data for the array of data
and then I use this new array in the cell renderer with an input

JS - Advice on how to merge multiple user input to one form field design

I have a page that allows users to enter a lot of information about them (metadata) they can then click on a icon which opens a modal window containing a googlemap which allows them to add locations, and a title for that location.
Using mootools I can pass the value of a form field back to the original form, using onclose. The main page form then has a single hidden input field, which goes into the database as one field, serialised.
The problem is a user can add as many locations as they want, there are also 3 types of location. Each with its own set of co-ordinates, which can be single or multiple!
So I want to know the best way to handle all of this data, is it possible to load it into one form and then use Moo to submit that form to a single form field, or can I use moo to just append all the information into a single hidden input field, but if I do that, how does user input come into it. Im stumped and looking at some suggestions on how to set this up in the 'best' possible way.
Currently I have a table, and each item is added as a new row, by JS when a user clicks on the map, it creates a new row with the details about the click, item and then a user input field.
If its a single location then its added as 'placemark', a user input field for the name and then the co-ordinates go into a 3rd table cell.
However if its a shape, then the first cell contains 'shape', user input field for name/description, and the third cell contains a list of co-ordinates one for each point, this is the same for lines.
The problem I have is I could write it all to a single form field, but then how do I allow for user input of the titles, I need to use a form field for that? The other option is to take each row from a table and input it into the single form field, seperated by a pipe or similar, but then im not sure if I can read from other form fields.
I hope the above makes some sense!! All feedback welcome!
Im using mootools for this, but providing I can get my head around the layout then that should not really be an issue.
I would suggest that you use an object to maintain all of the location data while the user is making their selections. When, when the form is submitted, serialize that data into a hidden field as a JSON object.
So, when the user clicks in the map window, you record the info in the object, in addition to the table. The populated object would look like this:
var usersLocations = {"locations": [
{"type": "point", "coords": [100,200]},
{"type": "line", "coords": [[200,300],[400,500]]},
{"type": "shape", "coords": [[200,300],[400,500],[1000,1500]]}
]
};
Mootools may have some JSON methods, but if not, look at http://www.json.org/js.html for working code. You can use JSON.stringify() to convert the object into a plain string suitable for saving in the DB, and when you get that string back out, you can use JSON.parse() to turn it into an object again.
As for handling the user input, you could write the table to the page just as your do now (or base it on the above object). Then when the user enters something in one of the fields, copy the value into the usersLocations object. So have an onBlur event handler on the input field that updates the data structure (something like this) :
usersLocations.locations[0]["type"] = "<what the user typed>";
are you looking for something like this?
usersLocations.locations[0]["name"] = document.getElementById("location0name").value;

Categories

Resources