Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • Isomorphic
    replied
    Wow. We were trying to give you a chance to admit to being difficult to help, and create some goodwill, but instead you've doubled down.

    You've again raised autoFetchData vs just calling fetchData(). This is an exceedingly trivial code change, not even worth raising a single time, but you've raised it perhaps 4 times now.

    And you're still talking about how you can't use dataChanged and dataArrived, even though you obviously can if the custom property is simply stored on the component, instead of (or in addition to) the DSResponse.

    This is something like the 5th thread with you where we've had this problem.

    So, we're done. It just doesn't make sense to invest so much of the limited community forums time we have in helping someone who is easily 10-100x more difficult to help than other developers. Please do not expect further responses on this or other threads.

    Hourly Support plans are available, and perhaps purchasing the smallest denomination of that plan would help you to focus your questions and better utilize free resources (the docs, ChatGPT).

    Again, make sure to make good use of ChatGPT. We use it constantly and it is extremely useful if your questions are specific and well-phrased. If your questions are vague and lack critical context, you will get responses that are not as useful. The same thing happens with humans, but ChatGPT will talk to you all day until you finally narrow in on the problem. However, we cannot: our time is finite, and we have to prioritize.



    Leave a comment:


  • wallytax
    replied
    And the question you've asked on ChatGPT still doesn't answer my situation that I want to access that response inside dataChanged() or dataArrived(). I need the data there and transforming the response inside the data source is not the solution to that question. As far as I know, I cannot access the response after that.

    Leave a comment:


  • wallytax
    replied
    It's funny and painful you mention ChatGPT: I didn't want to bring that to the table. I've tried that actually and of course I had a different search command. One of the suggestions was using fetchData() which still doesn't fix the "auto fetch" behavior. I don't think I have the answer at the moment. It also gave me solutions with non-existing properties that didn't work. I will share the link to that chat, hope it is accessible and I have most likely asked the wrong questions.

    It's not my goal to get these long discussions and I will probably stop asking questions, because I get this very negative energy from asking those questions and getting these kind of replies. I'm not a paying member either, so I understand your point. I was also hoping for other users to respond as well.

    Some of my questions might have also been useful as positive criticism, but I probably failed in doing that. Sorry for that...

    Leave a comment:


  • Isomorphic
    replied
    This was 42 posts to get to a very basic result, where the approach is covered in the QuickStart Guide and just a single line of actual logic is required. This keeps happening with your threads.

    We have previously asked that you make better use of ChatGPT to avoid this severe drain on community resources.

    .Just a note that ChatGPT gets the approach exactly correct on the first try:

    https://chatgpt.com/share/66e8834d-c...c-22b0990c6168

    Prompt: "I'm using Isomorphic SmartClient with a RestDataSource and a backend based on Ruby on Rails. What client-side code do I need to write to pick up a custom property that my backend sends, and copy it to the DSResponse or elsewhere? Can you show an example?"

    It then produces this code and explains the approach. The only thing wrong here is no call to Super().

    Code:
    isc.RestDataSource.create({
        ID: "myRestDataSource",
        dataFormat: "json",
        dataURL: "/your-endpoint",
        fields: [
            {name: "id", type: "integer"},
            {name: "name", type: "text"},
            // Define other fields here
        ],
    
        transformResponse: function (dsResponse, dsRequest, data) {
            // Assuming your backend sends a custom property, e.g. 'customProperty'
            if (data && data.customProperty) {
                // Copy 'customProperty' to DSResponse or another place as needed
                dsResponse.customProperty = data.customProperty;
            }
    
            // Return the modified DSResponse to proceed with default behavior
            return dsResponse;
        }
    });

    Leave a comment:


  • wallytax
    replied
    Thanks for the clear explanation! I will implement it like that!

    Leave a comment:


  • Isomorphic
    replied
    wallytax, this is an extremely simple situation, well described in the QuickStart Guide, which requires you to write one line of logic.

    Unfortunately, in that one line of logic you are required to write, you made an elementary programming mistake, which we helpfully pointed out - it's just the lack of a null check.

    That's literally it.

    Specifically, as we said in post #25, your transformResponse() logic just has a simple flaw - it needs a null check. Otherwise, your own code assumes that every single one of your server's responses on that DataSource has that custom property. And whether it is present or not, it's going to overwrite the property you are trying to set on your component.

    This is not a framework requirement, not a framework flaw. It is a simple logic bug in your override method, which we pointed out for you.

    Correct the bug in your own code and you will be fine. You will have implemented the simple solution that was explained in the QuickStart, and then here, multiple times.

    There is no need to switch between autoFetchData and fetchData(), even though that is extremely trivial - it's just not relevant.

    You literally just need a simple null check in the one line of code that the system requires you to write. That's it.

    Leave a comment:


  • wallytax
    replied
    Choosing a solution has consequences for other things. As an example the "auto fetch data". Simply saying I should use fetchData() is - IMHO - not enough, because that has consequences for that auto fetching: I need to know where to put the initial fetchData() and most likely keep track of it being called for the first time. More or less rebuilding the auto fetch behavior and that feels uncomfortable.

    Leave a comment:


  • wallytax
    replied
    Okay, so I would simply need to check in the dataChanged() handler if response.estimatedTotalRows != null? That would be an easy fix.

    I would prefer calling fetchData() if that gives me access to the response (which should be the case). But in this solution, I would need to disable autoFetchData? If so, where would I place the initial fetchData() that mimics the autoFetchData()?

    Leave a comment:


  • Isomorphic
    replied
    3) Copying the property over to the component self in transformResponse() seems to work but a post from Isomorphic suggests this means the row count must also be returned in non-fetch operations, which is unwanted.
    No, we said that your logic assumes that the estimated rows are returned every time. You simply need to adjust your logic with a null check.

    And also the whole problem is avoided if you just call fetchData(), or via myriad other ways.

    In a nutshell: this is a very simple and routine problem, with a solution explained in the QuickStart Guide, which works.

    Leave a comment:


  • wallytax
    replied
    So far, there is NO solution for this particular situation.

    1) Have the server return the "estimatedTotalRows" in combination with "progressiveLoading": true as suggested in version 14 doesn't work with the latest snapshot (at the moment of writing 2024-09-15). In an earlier post I've already mentioned I've looked into version 14 for just a couple minutes after a suggestion from Isomorphic. At least, I don't see a way of retrieving the "estimatedTotalRows" in events like dataArrived() or dataChanged().
    2) Copying the property over in transformResponse() to the response variable in the data source doesn't work either: not accessible from the grid's dataArrived() or dataChanged() events.
    3) Copying the property over to the component self in transformResponse() seems to work but a post from Isomorphic suggests this means the row count must also be returned in non-fetch operations, which is unwanted.

    I've dropped every attempt, because it simply costs way too much time and reverted back to the original implementation which only causes a warning in the browser's developer console.

    Leave a comment:


  • Isomorphic
    replied
    We're not sure why a second approach is being considered here, since there is already a solution that simply stashes the property on the component, or elsewhere. We would not recommend adding a field to the DataSource for this, as that would place it in every record and/or require iterating over all records on the server to add the property.

    It would also require adding this field to every DataSource, and simply put, it's not a field of the record, it's a field of the overall response, like totalRows.

    So we would recommend returning to having the row count as a property of the overall response, which is also how it's implemented in 14.0, meaning you will be able to use the new 14.0 features immediately by just renaming your property to match and deleting your extra code.

    Leave a comment:


  • claudiobosticco
    replied
    Originally posted by Blama View Post
    It is important to have a field myCustomRowCount in your datasource, as it wont be in the data otherwise, I think.
    unless you have dropExtraFields=false

    Leave a comment:


  • Blama
    replied
    Originally posted by wallytax View Post
    Hi Blama , so far no success (yet). My main concern is how to retrieve the actual record containing that extra information. Could you give me a hint of what that dataArrived() handler looks like?
    Not really, as I use SmartGWT, but it will be something along the lines of:
    Code:
    dataArrived : function (startRow, endRow) {      
        for (Record r : this.data.getRange(startRow, endRow)) { // or getAllCachedRows()?
                  if (r.myCustomRowCount) {
                         mylabel.setContents("We have " + myCustomRowCount + " records");
                         break;
                 }
        }
    });
    It is important to have a field myCustomRowCount in your datasource, as it wont be in the data otherwise, I think.

    Best regards
    Blama

    Leave a comment:


  • Isomorphic
    replied
    Originally posted by claudiobosticco View Post

    sorry, I misunderstood the sentence in the QuickStart Guide "you can override DataSource.transformRequest() and DataSource.transformResponse() and add Java code to handle those cases", and I thought that "and add Java code" was also referred to the transformRequest.
    That's a typo, it should say JavaScript. Too much sharing between the SmartGWT and SmartClient QuickStart Guides in this case! We'll get it fixed.

    Leave a comment:


  • wallytax
    replied
    Hi Blama , so far no success (yet). My main concern is how to retrieve the actual record containing that extra information. Could you give me a hint of what that dataArrived() handler looks like?

    Leave a comment:

Working...
X