Google App Maker: change calculated datasource Query page size programatically - google-app-maker

How do I change the query page size of a calculated model. I have it set to 10 by default but, upon a user searching for records that contain a specific string, I'd like to display all records and remove pagination. is this possible?

The correct way of doing this would be to set the page size to 0 on the client by doing the following (this is assuming you are directly referencing your datasource):
app.datasources.YourDatasource.query.pageSize = 0;
This is the client solution. If you where comparing specific string in your datasource Query Script or through another server script then it would be as follows:
query.limit = 0;
Hope this helps.

Related

Use SSRS report parameter to accept comma separated integer from ASP.NET web app

In SSRS I have a parameter which is of type integer.
Parameter values are bound from dataset, so that after the report gets loaded we can select parameter and run the report.
My situation is I have to pass the same parameter from web app without disturbing the existing functionality. Like "1,2,3" these are Id's which exists in the dropdown.
Elaborating the issue:
I have a query in SSRS dataset which takes a parameter employeeIds (this is a multi select parameter) query is something like this where EmployeeTable.Id in (#employeeIds)
When I used SQL profiler and saw the query executed against my database, it looks like this EmployeeTable.Id in (21,34,56,81)
Which is good, all works well till here. Now I need to call same report from a ASPX page without showing SSRS Filters pane (So I have to construct my params and pass to SSRS report)
Here is how I tried to passed the parameter
parameters(10) = New ReportParameter("employeeIds", "21,34,56,81")
This is throwing error as below
Cannot cast varchar to integer
If I change my Report parameter to string that will break SSRS Parameter filter logic, so I cannot do that. Without disturbing current working SSRS report how can I pass this param from code to Report?
Any help would be highly appreciated!
If I get it right you're trying to open the report in an aspx page and want to open it with your parameter employeeIds set to specific values. So you're looking into setting the parameter value of employeeIds to many values at once.
That could look like this:
parameters(10) = New ReportParameter("employeeIds", new string[] {"21","34","56","81"})
When providing multiple values to a parameter you need to put them in an Array. Have a look here for more info.

Datasource query limit is different of page size

In AppMaker I have a calculated datasource and I've set its page size to 10.
In the function I call to return the records (queryRecords), the limit parameter is set to 11 (I don't change it on front side).
Why ?
That's a good catch. App Maker sets the limit to page size + 1 on all queries because it needs to look ahead to see if there are more pages or not (this allows us to fill in the "lastPage" property because we looked one ahead and found a record). But for calculated data sources this is pretty confusing, I'll file a bug to look into this. At the very least it needs some clear documentation.
I think if you did try to return 11 records, it should only show 10 on the client, and fill in the last page property appropriately.

Count of the icon tab filter

I would really like to understand how to use the "count" property of the IconTabFilter for SAPUI5 to dynamically show the count of the result set of a table.
I have the following code -
<IconTabFilter
count="{DataSet/$count}">
<Table items="{DataSet}">
But the count is not filled automatically.
I am using an oData model that is bound on the view level. I do not want to make another backend request just for the counts. What am I doing wrong here? Is there a different mechanism that can be used?
I also tried using the updateFinished event on the table to then get the count and set it via JS but the event is triggered only on DOM placement of the table. In my case the table is hidden behind the IconTab and is not placed into the DOM till the first time the user clicks the tab so its useless.
Really would appreciate some insight into how to use this!
Thanks!
Okay, so what I did was I bound my information to a local model and did an oData $expand query to fetch the entire pages information in one call.
This worked out for me because I had several sets of data to be fetched. Before they were bound individually to tables, now they are all in one query.
In the .done() method of the call I just used the setCount method of the IconTabFilter to set the count as per the return data set.

gridview asp.net

I have a gridview which was working fine with a small dataset in development. In production it has to bind to thousands of records, which is making it slower to load. Is there a way to improve performance, like retrieving the data during gridview pageindex changing?
Also chances are you only want to bind it once. So you should (if not already):
if(!IsPostback)
{
DatabindGridLogicHere();
}
This way your GridView will only have to hit the db the first time to get the data.
First and formost turn off ViewState.
You should tell your datasource to take less records and then enable paging in your grid and datasource.
You can enable "AllowPaging" property to true in your GridView and give a page size say 10. Then Write your data retrieval logic to return a batch of data instead of the whole set of data at once.
When you write the SQL query make sure to order it by an ID.
Thus if the page index is 1 you can take the first batch of data by passing page index of 1 and the page size of 10.
Logic will be;
SELECT [RequiredFields]
FROM [YourDataSource]
WHERE (Id>=((PageIndex-1)*pageSize) AND Id<(PageSize*pageIndex)) ORDER BY Id
In the first page it will return first set of entries of those Ids starting from 0 to 9. In the second page it returns entries of those Ids starting from 10 to 19 assuming the pageSize is 10. You can change the page size and the query logic as you wish.
But if sorting is enable then this will not produce accurate results.

What is the best approach for this CRUD search page in ASP.NET

I'm building a heavily CRUD based ASP.NET website and I've got to the phase of the project where I'm trying to build a search webpage that shows the user different subsets of a certain important table based on parameters they enter such as dates and different text fields.
I can't use a fixed SQL statement, because depending on whether they search by date or by something else, the SQL would be different, so instead I have been generating a results list using a table web control that starts out invisible and then is filled and set to visible once the user identifies a search they want to make. I used a table control because its easy to create and modify in the code behind, and I was able to make the needed calls to the database and populate that table as required.
However, the second thing I need with this search page, is the ability to allow the user to select a record from the results and then go edit it using the rest of the CRUD based pages on the site. To do that, I created asp:buttons in the table and gave them all different ids and the same event handler. But since I created the buttons dynamically, it seems the event disappears on callback and my scheme fails, so I'm taking a second look at how to do this.
My current code for the events looks like:
tempcell = new TableCell();
Button tempbutton = new Button();
tempbutton.Text = "Go";
tempbutton.ID = "gobutton" + rowN;
tempbutton.Visible = true;
tempbutton.Click += new EventHandler(tempbutton_Click);
tempcell.Controls.Add(tempbutton);
temprow.Cells.Add(tempcell);
My results table is declared like this:
<asp:Table ID="ResultTable" visible="false" runat="server"
GridLines="Both" CellSpacing="8">
</asp:Table>
I'd like to be able to identify which record the user selected, so I can send that info on to another page. And of course, I still need to be able to generate results for several different search criteria. Currently I have date, template and code based searches that lead to different stored procedures and different parameters based on what the user has entered.
Any suggestions on this? It seems like the data grids and repeaters require SQL statements in advance to work properly, so I'm not sure how to use them, but if I could then the item command approach would work with the buttons.
Your event will hook up successfully if the button is recreated in the page load event.
Otherwise, use a GridView. It is the perfect solution for simple CRUD, and you can control it as much as you need.

Resources