Drupal 9 - How to pass view data to javascript - javascript

I have a custom module with a view that lists some data from a web service and has some filters in it (date, numeric, combos, etc).
I need to modify some filters when others change their value. For example, When the user changes the date, I have to change the selected value of a combo box.
I was trying to pass the filter values to a javascript file, but I couldn't find a way yet.
I tried using the "page_attachments" hook and a controller but none of them work.
Can somebody point me in the right direction on how I can do this?
Thanks in advance.

Related

Creating A Multi-select in React that accepts values not found in dropdown options

I need to create an input on my reactjs application where, I have an array of names populating a select. Here, when a user types a name that does not exit in the array used to populate the select, he should have the option to still tag this username into the selected list( indirectly a new item on the list). Also, the user needs to be able to tag multiple users.
It should work exactly like the Multiselect of react-select Component https://jedwatson.github.io/react-select/ except for the fact that, selected values also accept values which are not part of the dropdown
If there are any existing solutions to this in react, I will really love to take a look at them.
thanks and waiting for your help
Isn't this already supported via the Creatable version of the react-select?

jQuery UI Multiselect does not render items in the order saved in database

I'm using jQuery UI Multiselect plugin: http://www.quasipartikel.at/multiselect/. When I select items and save them to a database, I also keep track of their order and save it in the database, too. When I load the items (of course I order them in my query by their order values), they are set as selected but the plugin orders them not by the order I want but in its own way. Since the plugin is applied over a <select><option value="ID of the item"></option></select> elements I know that it uses <option> values (the IDs from database) to handle ordering. I've been looking in the documentation, but could not find anything to guide me further. I'd be very grateful if anyone has any idea or has encountered this problem before and solved it, to help me.

Fully custom lightbox in dhtmlxGantt

Hi there,
I'm looking at using dhtmlxgantt as a way of building up an itinerary i.e. you add items at specific days throughout a period (most likely 2 weeks)... However, there are quite a few extra variables that I need to store along with the standard info of dates etc. There are a series of 4 dropdowns which populate the next one via AJAX.
I know I can add custom controls into the lightbox but these will not work via AJAX when the previous dropdown is changed. I was hoping that I'd be able to make a fully custom lightbox which then passes everything back to dhtmlxGantt but I can't seem to find away...
It looks like it's possible in the scheduler product (http://docs.dhtmlx.com/scheduler/samples/02_customization/16_custom_form.html) can we do the same with Gantt?
Thanks in advance,
Adam.
You can just redefine gantt.showLightbox method and show your form from there. And then use public API to save changes - gantt.addTask, gantt.updateTask, gantt.deleteTask
Here is a crude example:
http://docs.dhtmlx.com/gantt/snippet/5e134aa1

how to populate the state and city in my project without using AJAX and refresh page?

I am looking a sample for the functionality where there are 2 drop downs. One is 1 is State/Province and the 2rd is City. Based on the state drop down selection, city drop down values should be populated.
I need sample database design also....
Could anyone please help me out on getting a sample for this.
Regards
padman..
With neither Ajax nor refreshes? Bad idea, unless you have a very limited number of state/city combinations--otherwise the HTML/JavaScript you send will be huge.
Otherwise it's a simple dependent select, which is searchable on the web. The nutshell version is that when your state changes, you take the value of the selected state option, use it to look up cities in a map of state id => cities, and use the cities collection to populate the second select box.
The state/cities JavaScript structure is created on the server side using whatever template mechanism the rest of the app uses (I assume JSP or Velocity since you're using Struts 1).
DB DB design for what? States and cities? Have a table of states. Have a table of cities with a state id foreign key.

Updating GridView without postback using javascript

I have a gridview and a dropdownlist on my page.
The gridview is binded through code behind with some columns. Among these price is also a column.
My scenario is to change the price field based on the dropdown criteria.
The price column consists of values in "lakhs", and i need to change them as crores or usd or some other format as per dropdown.
I don't want to go for postbacks. I want these to be implemented using javascript.
(These changes are for user conversion. They need not to be saved on database)
Thanks in advance
Madhu
You have two options. If you don't want to go for any response from the server (i.e. you don't want to make an AJAX call), you could populate a hidden field with a list of comma-delimited values that correspond to your dropdown values. It's an ugly approach, but it would work.
The other option is to make an AJAX call to a web method on the server (or possibly a financial service like Yahoo! Finance). When your dropdown selected value changes, that event fires a call to the server.
If you were able to indicate what platform you're using (PHP, .Net or other), someone will likely be able to provide more relevant examples and code samples.
Since the grid is rendered as an HTML Table, you can actually manipulate anything on the client.
I would pickup jQuery for the task

Categories

Resources