how to update grid row and reflect(refresh) it after update is done succesfully ?

1-) I have a grid. I implemented edit with dialog template which is placed a partialview for edit row data. How can i send updated data to controller when i clicked save button on edit dialog. 
2-) The another question how to reflect changes to grid after updated without refresh page.
3-) I want to change dialog save button css dialog radius. How can i do that ?

Bests,
Tümer

5 Replies

RS Rajapandiyan Settu Syncfusion Team March 4, 2020 12:01 PM UTC

Hi Tümer, 

Greetings from syncfusion support. 

Query #1: I have a grid. I implemented edit with dialog template which is placed a partialview for edit row data. How can i send updated data to controller when i clicked save button on edit dialog.  The another question how to reflect changes to grid after updated without refresh page. 
 
We have validated the provided details. We have prepared a sample with your requirement. In that sample, we have created a grid with dialogTemplate for edit feature. And bound the datasource in the Grid by using urlAdaptor. In this we handled all the crud action in server side by using insertUrl, updateUrl, removeUrl. 
 
By default when you save the edited data in the grid, it automatically sends the data to controller side and update it into the grid datasource. Please refer the below sample and documentation link for more information. 
 
 
 
 
<ejs-grid id="Grid" allowPaging="true" actionFailure="actionFailure" toolbar="@(new List<string>() {"Add", "Edit", "Update", "Delete" })" actionComplete="actionComplete"> 
    <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Dialog" template='#dialogtemplate'></e-grid-editSettings> 
    <e-data-manager url="/Home/UrlDataSource" adaptor="UrlAdaptor" insertUrl="/Home/Insert" updateUrl="/Home/Update" removeUrl="/Home/Remove"></e-data-manager> 
    <e-grid-columns> 
        --------- 
    </e-grid-columns> 
</ejs-grid> 
 
 
 
Query #2 : I want to change dialog save button css dialog radius. How can i do that ? 
 
By using the below CSS class you can customize the SAVE button of the edit dialog as you need.  
 
 
<style> 
    .e-dlg-container .e-footer-content .e-control.e-btn.e-lib.e-primary.e-flat { 
// customize the save button in the edit dialog as you want 
        border-radius: 50%; 
        background : violet; 
    } 
</style> 
 

Please get back to us if you need further assistance on this. 

Regards, 
Rajapandiyan S.              



Tümer March 5, 2020 11:12 AM UTC

Thank you for your response and example. I included datamanager to grid. The data rows are seem but rows's values are disappeared. When i clicked edit button edit dialog is opened and row data are associated with dialog inputs successfully eventhough they're not seem in grid rows. I've checked column name, they are same with model properties.
Where am i making mistake ?

Bests,
Tümer 


RS Rajapandiyan Settu Syncfusion Team March 6, 2020 01:43 PM UTC

Hi Tümer, 
 
Thanks for your update. 
 
Query : The data rows are seem but rows's values are disappeared. 

In ASP.NET Core, by default the JSON results are returned in camelCase format. So grid field names are also changed in camelCase. 
To avoid this problem, you need to add DefaultContractResolver in Startup.cs file. 

If the ASP.NET CORE version is 2.X then add the below code in startup.cs file 


public void ConfigureServices(IServiceCollection services) 
    services.AddMvc().AddJsonOptions(options => 
    { 
        options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver(); 
    }); 

 
 
If the ASP.NET CORE version is 3.X then add the below code in startup.cs file 
 
 
 
public void ConfigureServices(IServiceCollection services) 
          { 
                      services.AddMvc().AddNewtonsoftJson(options => 
          { 
                 options.SerializerSettings.ContractResolver = 
                    new DefaultContractResolver()); 
            } 
        } 
 


If you still face any problem, please get back to us with the following details to validate further on this. 
 
  1. Share the full grid code.
  2. Share any video demonstration of the reported problem.
 
Regards, 
Rajapandiyan S.              



Tümer March 7, 2020 07:04 PM UTC

That works now thanks. There is another problem i can't post radiobutton value and when i clicked edit radiobutton comes a default value not selected data row value. 
Other input areas are ok but radiobutton selected is post always 4. How can i fix it ?

      <div class="form-group row">
            <label class="col-lg-2 col-form-label">Süre Birimi</label>
            <div class="col-md-1">
                <ejs-radiobutton id="editDayDuration" label="Gün" name="editPackageDayDurationType"  change="editOnChange" value="1" checked="true"></ejs-radiobutton>
            </div>
            <div class="col-md-1">
                <ejs-radiobutton id="editWeekDuration" label="Hafta" name="editPackageDayDurationType" change="editOnChange" value="2"></ejs-radiobutton>
            </div>
            <div class="col-md-1">
                <ejs-radiobutton id="editMonthDuration" label="Ay" name="editPackageDayDurationType" change="editOnChange" value="3"></ejs-radiobutton>
            </div>
            <div class="col-md-1">
                <ejs-radiobutton id="editUncertainDuration" label="Süresiz/Belirsiz" name="editPackageDayDurationType" change="editOnChange" value="4"></ejs-radiobutton>
            </div>
        </div>


RS Rajapandiyan Settu Syncfusion Team March 9, 2020 12:16 PM UTC

Hi Tümer, 

Thanks for your update. 

Query: There is another problem i can't post radiobutton value and when i clicked edit radiobutton comes a default value not selected data row value.  
 
We have validated the provided details and suggest you to follow the below workaround to achieve your requirement. In that, we have used two reference variable btnchecked and btnchanged to store the value of radiobutton. 

In the actionBegin event of edit we have stored the radiobutton ( from the row data ) value in the btnchecked variable. In the created event of radioButton we have checked it with respect to the btnchecked value. 

And then we have stored the changed value of radiobutton in btnchanged variable in change event of radio button.  After that we have updated that changed value to the grid dataSource by using btnchanged value in actionBegin event of save. Please refer the below code example sample for more information. 


[index.cshtml] 
 
<ejs-grid id="Grid" allowPaging="true" actionBegin="actionBegin" toolbar="@(new List<string>() {"Add", "Edit", "Update", "Delete" })" actionComplete="actionComplete"> 
    <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Dialog" template='#dialogtemplate'></e-grid-editSettings> 
    <e-data-manager url="/Home/UrlDataSource" adaptor="UrlAdaptor" insertUrl="/Home/Insert" updateUrl="/Home/Update" removeUrl="/Home/Remove"></e-data-manager> 
     . . . 
   </e-grid-columns> 
</ejs-grid> 
 
<script id='dialogtemplate' type="text/x-template"> 
    <div id="dialogTemp"> 
    </div> 
</script> 
 
<script> 
   var btnChanged; 
    var btnChecked; 
 
    function radioBtnChange(args) { 
// stroe the changed value of radiobutton 
        btnChanged = args.value; 
    } 
    function actionComplete(args) { 
        if (args.requestType === 'beginEdit' || args.requestType === 'add') { 
            btnChanged = ''; 
             . . . 
           } 
            if (args.requestType === 'add') { 
                var ajax2 = new ej.base.Ajax({ 
                    url: "/Home/AddPartial", //render the partial view 
                    type: "POST", 
                    contentType: "application/json", 
                    data: JSON.stringify({ value: args.rowData }) 
. . . 
                }); 
            } 
        } 
    } 
 
    function actionBegin(args) { 
        if (args.requestType == 'save') { 
// updating the saved value 
            args.data.gender = btnChanged; 
        } 
        if (args.requestType == 'beginEdit') { 
// updating the checked value while editing 
            btnChecked = args.rowData.gender; 
        } 
    } 
 
    function radioBtnCreated(args) { 
        if (this.value == btnChecked) { 
// checked the radiobutton with datasource value 
            this.checked = true; 
        } 
    } 
 
    function appendElement(elementString, form) { 
         . . . 
   } 
</script> 
[Addpartial] 
      <div class="form-row"> 
            <h6 style="padding-left: 17px;">Gender </h6> 
            <div class="form-group col-md-4"> 
                <ejs-radiobutton id="radio1" label="Male" name="gender" change="radioBtnChange" value="male"></ejs-radiobutton> 
            </div> 
            <div class="form-group col-md-4"> 
                <ejs-radiobutton id="radio2" label="Female" change="radioBtnChange" name="gender" value="female"></ejs-radiobutton> 
            </div> 
            <div class="form-group col-md-4"> 
                <ejs-radiobutton id="radio3" label="Other" change="radioBtnChange" name="gender" value="other"></ejs-radiobutton> 
            </div> 
        </div> 
[editpartial] 
     <div class="form-row"> 
            <h6 style="padding-left: 17px;">Gender </h6> 
            <div class="form-group col-md-4"> 
                <ejs-radiobutton id="radio1" label="Male" name="gender" change="radioBtnChange" created="radioBtnCreated" value="male"></ejs-radiobutton> 
            </div> 
            <div class="form-group col-md-4"> 
                <ejs-radiobutton id="radio2" label="Female" name="gender" change="radioBtnChange" created="radioBtnCreated" value="female"></ejs-radiobutton> 
            </div> 
            <div class="form-group col-md-4"> 
                <ejs-radiobutton id="radio3" label="Other" name="gender" change="radioBtnChange" created="radioBtnCreated" value="other"></ejs-radiobutton> 
            </div> 
        </div> 


Please get back to us, if you need further assistance on this. 

Regards, 
Rajapandiyan S. 


Loader.
Up arrow icon