I'm using transformedData method as said in this post but with a different propose. I want to export the grids data. I was following 'Suggestion 2' in this post but then I realized that dataView method returns only the current page rows. I want to get filtered rows but from every page (from transformedData documentation that would be the second option: "2. After filtering before paging"). However I've tried and it doesn't work correctly. It returns the result from the last used transformedData method.
Here you can see this odd behavior.
I need to get the records after filtering and sorting but before paging. How can I do?
Hello intecomp,
Now I've got your point and after further testing of your code I believe that the returned result due to the transformed data call is correct. The explanation for that is the following: you're calling transformedData method multiple times within the 'useTransformedDataFewTimes' function and with every next time the data is transformed according to its previous state. Therefore when you're calling afterfilteringbeforepaging transform execution for the second time (var afterfilteringbeforepaging2 = dataSource.transformedData('afterfilteringbeforepaging').length), it will transform the data based on the previous transformation call (var afterfilteringandpaging = dataSource.transformedData('afterfilteringandpaging').length) which returns 3 as result. This transformation schema will apply also in the button click event, where you're calling the function and the end result will show only 3 records. So please note that the consequently call of transformeData API method applies on the previously made transformations, it does not start every time from the initial state of the data source. If you want all the records to be shown after transformation of the data source, then you may remove this function call if not necessary for your requirement or please explain me what is your exact purpose of using this function in the current scenario. Waiting for your reply.
Regards,
Tsanna
Do you really see the same results? I've run both scripts I gave you in Firefox, Chrome and IE11 and they always show different results. In both cases I'm calling 'afterfilteringbeforepaging' so I expect to get the 9 names in the list when the buttons is clicked (unless, of course, you applied any filter before). This first script does what expected, you click the button and the 9 names appear below. However this second script only shows 3 names (those from the first page) although it is also using 'afterfilteringbeforepaging' and its only difference is calling 'useTransformedDataAFewTimes' which, as you said, does nothing (only sets a few variables without even using them).
I want to use transformedData method with 'afterfilteringbeforepaging' and get the all rows that match the filter criteria whether they are in the current page or not. This works "at the beginning", but after a few calls to the method, 'afterfilteringbeforepaging' returns the last result of the method (either 'afterfilteringandpaging' or 'priortofilteringandpaging').
Hi intecomp,
Actually 'useTransformedDataAFewTimes' function in your code does nothing. You have declared only several variables of the transformedData object in this function and this does not affect the end result. Since you're using 'afterfilteringbeforepaging' as transformed execution, then the end result should contain only the results from the current page. I tested your sample and it does exactly the same. What do you find for inappropriate behavior in this case? Please explain me what do you expect to see after the transformation, you may give me also an example to understand you better. Waiting for your reply.
Hello Tsanna, thanks for your reply but I'm afraid the bug is still there.
You were right about using the undefined filteredData variable but it wasn't the problem. I made a few changes to your script:
The script with those two changed works great, you can see it here: http://jsfiddle.net/u3jr6fs1/8/.
But then, I made a second script which adds the call to a function in the click event. That function only calls a few times the method transformedData. It doesn't even use the results. However, the behavior then changes. After that function's execution, the result from transformedData('afterfilteringbeforepaging') is wrong. This second script is here: http://jsfiddle.net/u3jr6fs1/6/.
Looking forward to hear form you,
Diego.
I investigated your sample in jsFiddle and I noticed that you're looping through an object that you haven't defined: 'filteredData'. I assume that while you were trying to adopt the code from this sample: http://jsfiddle.net/u3jr6fs1/ you didn't change the name of the transformedData object variable. I modified your sample and now it returns the correct data after filtering from every page: http://jsfiddle.net/u3jr6fs1/5/ as per your requirement. If you need further assistance, please let me know.