My controller returns results in a Array like this:
render (template: 'show' , model: [changes: changes])
Show is a default action and changes is an Array created with a query(createCriteria).
How can I make pagination in my index.gsp page which is displaying results in a HTMl div?
My problem:
Controller:
def list() {
[terminHistorie: changes, terminHistorieCount: changes.size()]
}
gsp:
<g:paginate controller="terminHistorie" action="list" total="${terminHistorieCount}"/>
Error: Tag [paginate] is missing required attribute [total] at C:/Users/matejb/Documents/NetBeansProjects/gutmann/grails-app/views/terminHistorie/index.gsp:309
The way pagination works is you first need to create a view using paginate tag, then on your show action you need to slice your changes. Meaning that the view will send the offset and max parameter and your createCriteria will query the database only for those data. Take a look at this page and then here to see how you can pass max and offset into your createCriteria method.
To see an example, see this page or create a new application with one simple domain and generate scaffolding for it. Grails will generate a paginated result for you.
Btw, if you are using ajax you might want to use remote paginate plugin.
Related
So I have a dynamic table in angular where im passing data in, then creating the table. I want to add some CSS in order to check the values then add some styling onto it. So if the value is a minus number, then display the data in red
I have used attribute data to check the actual data, which works fine until i call to typescript method to generate the data instead of hardcoding the data in, and this is where is goes wrong. So I want to call this method to get the data instead, and it just displays the method name instead of the method return
You can use the attribute binding of data instead of the interpolation if the data returned by the method is not a string - more details here
[attr.data]="getData(header, body)"
I'm trying to implement sort function to my table in angular, and all my data from my rest api does show up in the table. But the problem I get is when I click on arrow my data in table doesn't sort. My data comes from a method in other ts file witch get the data from rest api
What I have tried is followed this links but it doesn't work
Angular Material Table Sorting - Data Doesn't sort when inside a *ngIf condition
Sorting Not Working Angular Material Design Table
https://material.angular.io/components/table/overview#sorting
I have some problem to upload code
This is my controller code, the method to get code from rest api: https://imgur.com/a/qX2AcNJ
This is my code who should take a data from controller and show in html: https://imgur.com/a/OR0SQvH
This is the html file: https://imgur.com/a/q4FJmuK
Your table is missing the instruction on how sorting must be done. You should add the following to your table element.
<table ... (matSortChange)="sortData($event)">
Then you need to to add the sortData method to your ListComponent. A detailed example can be found at https://material.angular.io/components/sort/examples.
My goal is very simple and I would guess it is a very common goal among web developers.
I am creating a Rails (5.1) application, and I simply want to use AJAX to get the value of a specific cell in a specific row of a specific table in my database (later I am going to use that value to highlight some text on the current page in the user's browser).
I have not been able to find any documentation online explaining how to do this. As I said, it seems like a basic task to ask of jquery and ajax, so I'm confused as to why I'm having so much trouble figuring it out.
For concreteness, say I have a table called 'animals', and I want to get the value of the column 'species' for the animal with 'id' = 99.
How can I construct an AJAX call to query the database for the value of 'species' for the 'animal' with 'id' = 99 .
Though some DBs provide a REST API, what we commonly do is define a route in the app to pull and return data from the DB.
So:
Add a route
Add a controller/action for that route
In that action, fetch the data from the DB and render it in your preferred format
On the client-side, make the AJAX call to that controller/action and do something with the response.
Using 2sxc to create a new app with only:
- One content type
- 15 rows of data
- One view (razor, single cshtml file)
When I call the #foreach loop, only some of the data is shown in the list view (apparently the ones inserted in the current dnn module and only through the "new" button in the toolbar). If I add the row in the admin panel, it will not show. When I deleted the module and inserted it again, I can see the data in the admin panel, but not in my list view.
Attached screens.
I tried calling the data with:
#foreach(var Content in AsDynamic(Data["Default"])){...}
or
#foreach(var e in List.OrderBy(e => e.Content.Farmaco).Where(e => e.Content.Cat == "1")){
var Content = e.Content;
... }
but the result is the same.
Am I missing something really obvious?
DNN 9.1.1
2sxc 9.04.01
https://drive.google.com/file/d/0B-4bmuuNWVx2MUxxa0g1SExqUkE/view?usp=sharing
Yes, you're clearly not familiar yet with "raw data" and items-assigned to a modules.
In our code you get the module-data with Data["Default"], whereas the raw-data you would get from a query (then also with Data["Default"] or Data["Whatever-Name-Your-Stream-In-Your-Query"])
If you want to work with all data, you would again use a query, or App.Data["TypeName"] and build on that.
Check out http://2sxc.org/en/blog/post/12-differences-when-templating-data-instead-of-content
I am new in yii2 and i am using wbraganca/yii2-dynamicform widget in my view. My question is that I have to use more than two dynamic form in a single view. For single dynamic widget it works fine while saving from controller but others are saving just the last data of dynamic widget, while inspecting the post data in network array index for others except first dynamic form are not increasing (there index is only zero). Would you please suggest how should I have to do. How can I use multiple dynamic-form widget in single view. Thank you in advance.
I believe the problem must be in your view. You should ensure that each control has a unique name and then loop through the post variables in the controller.
<?= $form->field($modelx, "[{$i}]MyVariableName", ['labelOptions' => ['label' => false]])->textInput(['name' =>'myClassNameHere'."{$block}[$i][MyVariableName]"]) ?>
See the 'name' option in the code above. It gives a unique name to each field. Here the $block variable is a unique code I append to each widgetItem class in the DynamicFormWidget.
If I now look at my POST data, I see something like the following:
myClassNameHere0[0][MyVariableName]:1
myClassNameHere1[0][MyVariableName]:11
If this does not help - post a simply example that you cannot get working and I will have a look at it.