I have set up a CGridView widget in my application. It displays a list of user accounts. I also have two other drop down lists that basically filter out the users. My problem is that I cannot use the values from the drop down lists to filter out the users. What I actually need is to refresh the list of user accounts based on the selected values from the drop down lists.
How am I supposed to do that with Javascript?
Yes you use Javascript to do this. CGridView's jquery.yiigridview.js has $('#id-of-grid').yiiGridView('update', options) function which can be used for such things:
function(){// in your function
$('#id-of-grid').yiiGridView('update', {data: {value_of_list: $(this).val()}});
}
This will call the url that renders this view with a parameter value_of_list with the value selected in the drop down.
Edit:
The $('#id-of-grid').yiiGridView('update', options) signature indicates that you can specify which grid to update, and also the specific options to be sent. In the above example i have sent only data, i could have also specified which url to send the data to using url option. The full list of options can be seen in the link i have specified above.
Related
i'm using the PDO library in php to access a database and return some values into a table which need to be shown when the user first opens the webpage,
after this I want to implement a filter option, so that the user can input some data in a form field and the data shown is updated according to the filters set by the user.
I don't know how to update the DOM in this case, would it be possible to update the DOM using Jquery so that only the new values are shown in the table, or do i need to redirect to a new page/reconstruct my table with a full request/response cycle.
thank you for your help in anycase.
If I understand correctly, you want to output the data from the result of your MySQL query as a table, and then having a search bar which will filter the output table according to the search bar. What I would do is first use the data to generate a table and give it a css class. For the search bar you can use form or event listener to process apply your filter from the value in the search bar. For example you can loop the rows of the table and check if a column contain a substring of the search bar value(as an example, check with whatever criteria you prefer) and just add a css value display: hidden to the row, or restructure the table, there are many ways of doing it.
I'm using handlebars with a table with many columns. The table has data from my database, arranged by ID. A button on each row (list of users), will open up a modal dialog for user information. I have my list of users populated in my template with the users in an array as a handlebars template.
I want to be able to display the correct user data on the modal based on which user's button was clicked, as each row is a different id.
I am trying code like this:
{{{allUsers.html_button_id.userName}}}
But as I've seen in other questions like this one, they suggest I use a helper function. I have tried that too, and have a return var helper like this:
getDataFromDB : function(key, index, options) {
return key[index].value;
}
Where in use:
{{getDataFromDB userProfile index}}
But still not coming up with anything. I cannot put in a variable into that, it says that it is invalid. I have a button that has an ID, which I want to pass to this helper function so I can use the ID as the index to iterate through my array depending on which button the user presses. Any idea how to accomplish this? I feel like I'm close
Is there a way to programmatically change the collection of a gallery in wix. I have a wix store and I want to add costume filter options. I know you can add some in the editor but if the collection is empty I cant add it to the filter options and I don't want to have to go through the editor and add that filter every time I get an inventory of that product. So I want to use radio buttons and write my own filter code and if the collection is empty I want to display that or show some type of message. I have the coded filter successfully running a query to find all products that contain a certain "String". I want to take that array of products and populate a store-gridGallery programmatically but I don't see any properties of the gridGallery that allow me to do this. Any Suggestions??
You can replace the store grid gallery with a repeater, creating your own store product gallery. Then, using Wix Code inputs and wix-data filter, you can code your own set of filters.
e.g.
Assume you are using a dataset connected to a repeater to show the store products as a gallery. You can then set the dataset filter using
import wixData from 'wix-data';
export function filterElement_onChange(event) {
let value = $w('#filterElement').value;
$w('#dataset1').setFilter(wixData.filter().eq('a field', value));
}
I have an Ember app that has a template with several dropdown menus(the dropdown menus are in a component.hbs).
Inside the component.js, there is a custom array (ingredients) that takes objects from the model and filters them depending of the selections.
The problem is that the data doesn't refresh automatically for the following selectors, I have to refresh the website to be able to see the next options.
For example: 2 selectors: "recipies" and "ingredients"
A user selects "meatloaf". The ingredients selector, that would take the data from a custom array in the component, doesn't refresh itself in order to display only the ingredients for meatloaf.
I'm assuming this is happening because the component.hbs (and the ingredientes array)have been rendered and loaded when the user visits the website, but I need to find a way to refresh the ingredients array everytime a user selects a recipe
So, I just figured it out.
It was way more simple than I thought.
In the same action that is triggered when the user selects a recipe, I empty the array for ingredients, and then fill it out with what the ingredients related to the selection.
Define computed property in the component, which will be recalculated whenever selectedRecipe changes.
ingredients:Ember.computed('selectedRecipe', function(){
// do filtering stuff and return the result
return this.get('customArray').filterBy('name',this.get('selectedRecipe'));
})
How to validate the report parameters while running the report in WebViewer. I am using the eclipse to design the reports. I am using the date fields and some select boxes as parameters. But my requirement is - user should not type the date, he should select the date from date picker(jquery UI) and at select boxes I want some kind of validation at server side that is From Category select box should not be greater than To Category select box. I need to do this validation at server side with ajax calls. Is there any way to customize the dialog box to get this functionality or I should design new page to do that and link that report after validation.
I need export functionality also in my page, if i want that how to pass the selected parameters(Export Format, Pages, Auto) to report.
1 Validate Selectbox Parameters
For the validation of your Select Parameters, you could use a Cascading Parameter Group.
First you create a Data Set that is returning the possible values for your "from Category". Then you reate a New Cascading Parameter Group and select Multiple Data Set add a new Paramter(your "from Categroy Prameter") and select the just created Data Set to display.
Close the Parameter group for now, and create a second Data Set that is returning the possible values for your "to Category". Here you can use the Input of your "from Categroy Prameter" form the just created Cascading Parameter Group to limit the results to display.
Now go back to your Cascading Parameter Group and add a second Paramter based on your second Data Set. Make sure both parameters are configured as List Boxes.
If you now select a value for your "from Category" the allowed values for "to Category" will be dynamically updated.
2 Export input parameters for export formats
To export your input parameters simply add them by drag and drop to your Report Page. Parameters can be displayed in every Expression Field with be binding params["parameterName"]. If you just want to display them for a limited kind of Export Formats (e.g. display in .xsl but hide for .html) select the visibility Tab in the Property Editor and select "hide Element" "for specific outputs..." and select the format where you want to hide the field.
3 Datepicker Input
there is no plugin that I know that is providing the Requirement to BIRT out of the box. You can edit the .jsp that is taking the input parameters but here you are on your own. I would prefere to display the Input-Format of a date e.g. dd.MM.yyyy to reduce typo errors.