it is possible to use static LOV (default, newest, latest) to sort interactive grid by date column? I tried to use order by in query, but it's not allowed.
Thank you in advance
As far as I can tell (which means that someone might know better), you can't do that because interactive grid's select statement doesn't support order by clause; if you try to add it, you'd get
ORDER BY clause is not supported, use column sorting instead.
which means that - once you run the report - navigate to "Actions" menu, go to "Data" and choose the "Sort" option.
Can that help in what you're trying to do? Perhaps! How? By saving the custom report. So:
sort data any way you want
go to "Actions > Report > Save as", give it a name and save it
repeat these steps as many times as you want
when you're done, you'll see new option in the toolbar which will let users pick report they want, without having to manually sort data themselves. Something like this (a simple interactive grid based on Scott's emp table):
Odoo 13.
I got two float fields: time_given and timer.
I have created a widget for 'timer' field. My widget works as real-time clock or some sort of timer. The problem I have encountered is that I want to change the style of 'time_given' field based on the following condition:
((time_given - timer) <= 30 sec) i.e less than 30 seconds left
To change the style of the field the widget attached to is pretty easy, but I am not sure hot to get access to other field elements in the form view I need and make some visual manipulations with them if needed.
I was able to get access to other field elements, change their style and add some text but the it is not a proper way.
this.__parentedParent.__parentedChildren
I get array of objects, then I loop through it and look for the field needed. After I found my target field element I am able to play with it.
For example:
$field_name.addClass('text-danger')
The way above works pretty fine but again as I said before, this is definitely not a proper way.
I was trying to find the right field element and add class to it by the following way:
$("[name='field_name']").addClass('text-danger')
It found the element, but did not add the class 'text-danger'.
I was trying my best by googling and reading the source code, but failed.
enter image description here
I have managed to solve this issue. Just used core.bus.trigger method mentioned in the official documentation.
P.s. In case if you are still interested how I did this in more details, just let me know in the comments section below.
EDIT: The reason why Excel was crashing was because getCellProperties() requires an object with the properties to extract as a parameter. I feel so stupid.
Context: I am building a Addin for Excel using the latest Office Javascript API.
Basically what I want to achieve is to extract and convert to JSON all of the attributes of the selected range. That means, getting borders, fonts, cell values, etc.. I have seen that there are some functions that enable me to get some of the properties for the entire range, however some functions will return null if all the cells in the selected range do not have the same values for a set attribute.
So far, I have thought of using selectedRange.getCellProperties(); where selectedRange is the user's current selection in the worksheet on every cell in the range, but for some reason Excel crashes whenever I try to use this function.
So, the only way I can think of is to extract these attributes manually for each cell in the selected range by using a loop inside a loop. This is of course not optimal for performance and I am confident that there is a better solution possible.
How could I go about doing this?
Thank you for taking the time to help!
Thanks for reporting this issue. I can repro the crash after removing parameter from getCellProperties. Crashing excel is not right, i have logged an internal bug to track.
From perf consideration, Maybe you could try getRowProperties API ? As you can retrieve all properties in a row together. and you can convert row properties into JSON string. The performance could be better.
The document can be found at https://learn.microsoft.com/en-us/javascript/api/excel/excel.range?view=excel-js-preview#getrowproperties-rowpropertiesloadoptions-
(--I'd like to add a comment under Raymond's answer, but i didn't have enough reputation, have to post a new answer :( )
As you already know the crash reason of selectedRange.getCellProperties(), how about making sure the parameter is not null ? getCellProperties is the most convenient way I know for your scenario.
I am working on a javascript based website project utilizing geojson data. My problem is that I have an object somewhere in the code and of course there are several properties belong to that object.
Let's say that it is something as follows:
pointLayer:{
title:feature.properties.parcelName
}
So, when I run the app, on the basis of this piece of code the "title" which appears on the screen becomes only the Parcel Name. However I would like one more colum from the geojson in a way that both of them will be merged and displayed as an whole. Or another option might be adding just a text other than adding one more column. I wonder if that is something possible to do.
Just to make it clear, I am trying to do something like this. I know that it is completely wrong. I am giving this one below just to show what I am trying to reach.
pointLayer:{
title:feature.properties.parcelName + feature.properties.parcelNumber
}
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I've been working with tables and a huge amount of data. There are a tables in my website with 10 thousand rows. This table has dynamic search, filters, etc. I've been using pure JavaScript considering performance, but it gets laggy with this amount of rows.
Do you guys know any alternative for pure JavaScript with better performance?
EDIT> I REALLY need to load the 10 thousand rows at once. I can load them all in the browser in 5 seconds. The main problems are the filters and search...
EDIT2> The search is dynamic. I can search by name and filter it by first character.
I've been working on it for months...
SEARCH:
search when the field has more than 3 characters and only when its length and characters has changed (onchange event on input may trigger multiple times when a character changes, so I make sure it only triggers once using some verifications)
each row that matches the searched string is coppied to another table. The original table is hidden and the new one is displayed.
when the user changes the search field or cancel the dynamic search, the new table is erased.
Conclusion: it's faster to create a new table with desired elements than hide the undesired ones.
FITLER
The rows are actually in 25 tables (A to Z + non-alphabetical characters)
When you select a character, only that table is shown
Conclusion: it's faster to hide a whole table than hide the
undesired rows
Thanks for the repplies. I've edited with some extra info so we can narrow the possible solutions...
I'm asuming you get the contents from database and load with with something like PHP (I'm going to asume PHP for now)
You could make the Javascript make an ajaxcall to a php-file which does the filtering (actually you should make the database do it, a lot faster!) and place the resulting table back on screen.
A faster method combined with the above might be this: Get all id's on the initial rows in an array and save those (in a session might work pleasant).
When you have to filter, don't make PHP get the whole table, just apply the filter to only the stored id's and send javascript the matching rows.
Then make javascript do something like this:
- set all visible
- set resulting id's to hidden (hidden in favor of remove, because I think a user might perform multiple filter actions?)
Another idea just popped in my head: If you don't need to display it on load, you can start the initial load with all tables hidden and a message "please search to display".
A common technique to handle this case is to load the data in memory or a subset of the data, and recycle your table rows such that you aren't actually ever creating thousands upon thousands of rows. You can get creative with this and create a web interface that seemingly scrolls endlessly but in reality you are just reusing dom elements and shuffling them around.
Most well-built data grid widgets whether they are on the web, mobile or even a desktop interface will employ this technique to handle your particular problem.
In most cases a user will never actually find themselves benefiting from seeing 10's of thousands of rows of data at once anyway.
fetch from the server only the things to be seen by the user, Like everyone has pointed out 10,000 rows needn't be there on that page.
you can use the concept of pagination and for every page few rows are fetched and shown . JQuery's Ajax is capable of calling the server side function to fetch rows to add them to your page.
don't know any backend details here, but in struts framework there is display:table tag and I believe in .NET framework there is GridView for pagination in the client side that you can look into
I'm just a student, newly joined to the community. Take what I say with a grain of salt.
I'm not sure why everyone is so much as blinking at the ten thousand rows business when we're measuring modern personal computers' memory in gigabytes.
Alright. I'm going to assume that what you're doing needs to be done in the browser, and so you can't switch to doing native code. In that case, looking for an alternative to Javascript won't get you much of anywhere. In the context of a browser, you're looking at an interpreted language. In terms of number of instructions the program ultimately has to run, the difference between one language or another is negligible in the face of how long it takes to be interpreted. Besides, Javascript has gotten nicely polished over the years.
So never mind that. There's a much more important thing to consider here, and it applies no matter what you're programming in or on: The cache(s). Igor Ostrovsky explains it beautifully; read it until you grok it.
So I'm guessing you have objects that would stringify to something like, "obj1 = {field-1:'a', field-2:'b', ..., field-n:'n'}". And you can select a field-i to sort by. The trouble with this is that when you sort by field-i, you're loading the entirety of obj1 into the cache, even though you don't need it. What you really want to do is load the field-i's forobj1, obj2, obj3, ..., objm all at once. So you look at an array, stringifying to something like: "field1 = [refToRow1, field1inRow1, refToRow2, field1inRow2, ..., refToRowM, field1inRowM]".
You might not be able to do fit all M rows in the cache, after all M==10000! But you can group them together into chunks that you could reasonably expect a cache to manage. Anyone got a good number for this? Say, 64kB? So you figure for each i in M you've got a reference, and a field that's probably just a reference to a short string (it'd be better if you could have the string itself right there, but I don't think Javascript works that way). So that's 8B? 8B*1024 = 64kB? Hell, if that's right, you could fit it all into the cache in two chunks, which means you'd want to do it in 4.
So now you've got a collection of smaller arrays, and you want to sort them. This is a classic application for B-trees. And while having a separate B-tree for each and every column in the table may seem like a lot, it's not.
Okay, so that handles sorting. You tell it to sort by a column, and the truth is it's already sorted! You're just repopulating the visible table using a different b-tree. You still need to handle filtering, but that's fine. You do some cache juggling as you find something to display and follow the reference to get the other fields, but I'd still expect this to go fast since you're skipping over so many rows.
Normally, I would say if you want to speed things up, look into multiprocessing. But I think browsers are still working to make that a thing with their Javascript implementations. Plus, while it would be well-suited for sorting, it would be a lot of effort to make it useful for the filtering part, and I expect you can do fine without.
I hope this isn't too scatter-brained, and that it gives you some ideas. Good luck!