Questions about Inserting and Updating a Record

I have several questions in regards to inserting and updating rows.  I tried to find easy answers on the docs but it is a little dark, PLEASE follow my questions one by one so you don't get confused, the project files are attached on a zip file. (I REMOVED MY KEY FOR SAFETY, INSTALL YOURS PLEASE)

1) My first question is... how do you customize the ADD button on the top? in the samples the button looks blue, mine looks ugly, please take a look at what I have... I do have a very simple grid that looks like this:


Now that you can see what I have, its a simple list of items, with Id, name (named TextValue), Description, and a boolean named isArchived, that you can see as checkbox.  Basically I received this list, and I filter the archived ones so these don't show.

Now, the behavior I want is explained as follow:

When Inserting:

  1. Create validation rules (which I did and work like a charm!)
  2. Take and send the item somewhere to be saved...
  3. if successful then add it to the list, if it fails, then show an error with some description of what happened.
I created a custom Data Adaptor, the problem is that in the examples, it assumes everything goes just fine and the item is just added to the list, which is not a real example... this takes us to my first important question...

2) My second question is: HOW do I notify something went wrong? please take the look at the following example:

If I run this, when adding a new item, it just stays there, doing nothing, no messages, nothing... 

In other words, in addition to the validation rules, we must know that something could go bad when sending this data to a remote db or remote API... how can we make this better? how can we let know the user that the information he/she provided was not saved because X did happen?

3) My third question: As you can see, I have a boolean field, called isArchived, I would like that everytime they want to update this field, they should have a confirmation, something like... "are you sure? YES NO"... using the Custom Data Adaptor I noticed that I can't inject IJSRuntime or have any interaction with the blazor component from the Update method, so in my point of view, there's no way I can show a modal or something and wait for the response before proceeding with the update... how do you do such thing?

4) My fourth question: I noticed that I want to abort an insert or update, I just don't do anything and basically, it will not do any changes or inserts, is this the right way to cancel such action? (this is not super-important but would like to know)

5) As I could not create a confirm button from the update method (as explained in my third question), I created a column with a button, that you can see here:


The idea was that if the button was outside of the Custom Data Adaptor, could interact with Blazor, here's how I created the button and the method it calls:

and the method it calls is called Archive as follow:

I created a reference to the grid, as I noticed that the grid was not reflecting the changes I made, according to what I need, if the record isArchived then it should not show, and it works the first time I click the button, the second time, it just makes all my records disappear... no errors, just not there anymore, or at least the may I know why?

Please call me at 832-292-0088 I do have remote access if you need it, so we can play with the sample project if you can't reproduce the problem.

Attachment: PROJECTTEST_8e3126dc.zip

2 Replies

RS Renjith Singh Rajendran Syncfusion Team February 21, 2022 01:49 PM UTC

Hi Guillermo, 
 
Greetings from Syncfusion support. 
 
Query 1 : how do you customize the ADD button on the top? 
We suggest you to refer the below documentation for more details regarding this requirement. 
 
Query 2 & 3 : if successful then add it to the list, if it fails, then show an error with some description of what happened. && My second question is: HOW do I notify something went wrong? please take the look at the following example: 
From your sample, we could see that you are throwing an exception inside InsertAsync method, in cases of validation failure for insert action. At these cases, throwing exception will trigger the OnActionFailure event handler of Grid. In the arguments of this handler you can fetch the error details and show the error based on your requirement. We have documented a similar topic on exception handling. Please refer the below documentation for more details, 
 
Query 3 : 3) My third question:  
We would like to inform you that, by default the action events(OnActionBegin/OnActionComplete) will be triggered when performing data related operations. So now when you update value to Grid, these events will be triggered. Now based on the RequestType you can customize your actions and show dialog based on your requirement inside this event handlers. Please refer the below documentation for more details, 
 
Query 4 : 4) My fourth question: I noticed that I want to abort an insert or update, 
You can prevent/cancel the default save action, by setting args.Cancel as true inside OnActionBegin event handler. 
 
 
<GridEvents OnActionBegin="OnActionBegin" TValue="Order"></GridEvents> 
 
    public void OnActionBegin(ActionEventArgs<Order> args) 
    { 
        if(args.RequestType.Equals(Action.Save)) //check for your conditon  
        { 
            //based on your condition prevent the save 
            args.Cancel = true; 
        } 
    } 
 
 
Query 5 : it works the first time I click the button, the second time, it just makes all my records disappear... no errors, just not there anymore, or at least the may I know why? 
We have considered a bug related to CustomAdaptor occurred in 19.4.0.52 patch release. We have fixed the issue internally and the fix for this issue will be included in our upcoming patch release which is expected to be rolled out on or before February 23, 2022. We suggest you to check this scenario once the release is rolled out. Until then we appreciate your patience.  
 
Regards, 
Renjith R 
 



RS Renjith Singh Rajendran Syncfusion Team February 23, 2022 09:34 AM UTC

Hi Guillermo, 
 
Query : it works the first time I click the button, the second time, it just makes all my records disappear... no errors, just not there anymore, or at least the may I know why? 
We have resolved the issue in our latest nuget release version(19.4.0.53). We suggest you to check this scenario by upgrading to our latest version to overcome the reported problem. 
 
Kindly check this from your side with our latest version and get back to us if you need further assistance. 
 
Regards, 
Renjith R 
 


Loader.
Up arrow icon