UI not refreshing after datasource of the grid is updated

Hi,

I have a grid with for example 5 columns, last one not editable (.AllowEditing(false)). When I edit a record, change some data and in server side I change the last column value. After changing datasource and loading again the view, I cannot see the change in last column.

Here is my code, and I am attaching some screenshots.

The view:
<div class="row">
    <ContentSection>
        <div class="col-lg-12 no-margin no-padding">
                @(Html.EJ().Grid<IEnumerable<object>>("ListaEquiposPorContrato")
                .Datasource(ds => ds.Json((IEnumerable<object>)equipos).UpdateURL("/Home/Update").Adaptor(AdaptorType.RemoteSaveAdaptor))
                .Columns(col =>
                {
                    col.Field("IdEquiposGeotab").IsPrimaryKey(true).Visible(false).Add();
                    col.Field("DatabaseName").HeaderText("Base datos").Type("string").Width("10em").Add();
                    col.Field("LicensePlate").HeaderText("Placa").Type("string").Width("10em").Add();
                    col.Field("DeviceType").HeaderText("Tipo").Type("string").Width("5em").Add();
                    col.Field("SerialNumber").HeaderText("Serial").Type("string").Width("10em").Add();
                    col.Field("Vin").HeaderText("Vin").Type("string").Width("10em").AllowEditing(false).Add();
                })
                .Locale("es-CO")
                .AllowScrolling()
                .IsResponsive()
                .AllowPaging()
                .AllowSearching()
                .EditSettings(edit => { edit.AllowEditing().EditMode(EditMode.Normal); })
                .ClientSideEvents(eve =>
                {
                    eve.EndEdit("jsActualizaGrillaListaEquiposPorContrato");
                })
                .ToolbarSettings(toolbar =>
                {
                    toolbar.ShowToolbar().ToolbarItems(items =>
                    {
                        items.AddTool(ToolBarItems.Search);
                        items.AddTool(ToolBarItems.Edit);
                        items.AddTool(ToolBarItems.Update);
                        items.AddTool(ToolBarItems.Cancel);
                    });
                })
                )
        </div>
        <div class="row">
            <div class="col-md-2">
                <br />
                <input type="button" id="btnAsignar" class="btn btn-primary" value="Delete" onclick="enviarEquiposChecked()" />
            </div>
        </div>
    </ContentSection>
</div>

<script type="text/javascript">
    function jsActualizaGrillaListaEquiposPorContrato(args) {
        $("#ListaEquiposPorContrato").ejGrid("refreshContent");
    }
</script>

-----------------------------------------------------------------------------------------------------------------------------

The controller:
public class HomeController : Controller
    {
        public ActionResult Index()
        {
            List<EquiposGeotabUI> lstEquipos = new List<EquiposGeotabUI>();
            for (int i=0; i<10; i++)
            {
                EquiposGeotabUI equipo = new EquiposGeotabUI()
                {
                    DatabaseName = "DB name " + i.ToString(),
                    DeviceId = i,
                    IdEquiposGeotab = i,
                    DeviceType = "Device type " + i.ToString(),
                    LicensePlate = "NKN-" + i.ToString(),
                    SerialNumber = "Serial No. 00" + i.ToString(),
                    Vin = "VIN0000" + i.ToString()
                };
                lstEquipos.Add(equipo);
            }
            ViewBag.Equipos = lstEquipos;
            return View();
        }

        public ActionResult Update(EquiposGeotabUI value)
        {
            List<EquiposGeotabUI> lstEquipos = new List<EquiposGeotabUI>();
            for (int i = 0; i < 10; i++)
            {
                if (i == value.IdEquiposGeotab)
                {
                    EquiposGeotabUI equipo = new EquiposGeotabUI()
                    {
                        DatabaseName = value.DatabaseName,
                        DeviceId = i,
                        DeviceType = value.DeviceType,
                        LicensePlate = value.LicensePlate,
                        SerialNumber = value.SerialNumber,
                        Vin = "RECORD MODIFIED"
                    };
                    lstEquipos.Add(equipo);
                }
                else
                {
                    EquiposGeotabUI equipo = new EquiposGeotabUI()
                    {
                        DatabaseName = "DB name " + i.ToString(),
                        DeviceId = i,
                        IdEquiposGeotab = i,
                        DeviceType = "Device type " + i.ToString(),
                        LicensePlate = "NKN-" + i.ToString(),
                        SerialNumber = "Serial No. 00" + i.ToString(),
                        Vin = "VIN0000" + i.ToString()
                    };
                    lstEquipos.Add(equipo);
                }
            }
            ViewBag.Equipos = lstEquipos;
            return View("Index");

        }

        
    }


Attachment: Screenshots_dc575394.zip

4 Replies

BM Balasubramanian Masilamani Syncfusion Team February 12, 2018 02:08 PM UTC

Hi Juan Jose Uribe, 
Thanks for contacting Syncfusion support. 
We have checked your query and we are able to reproduce the mentioned issue with your code example. To resolve the issue, we suggest you to refer the code sample below 
 
Please refer the code sample 
namespace Sample.Controllers 
{ 
    public partial class HomeController : Controller 
     ……………… 
public ActionResult NormalUpdate(EquiposGeotabUI value) 
        { 
            for (int i = 0; i < 2; i++) 
       ……………………… 
var ord = value; 
EquiposGeotabUI val = lstEquipos.Where(or => or.DatabaseName == ord.DatabaseName).FirstOrDefault(); 
val.DatabaseName = ord.DatabaseName; 
val.DeviceId = ord.DeviceId; 
……………………………. 
value.Vin = "newadded"; 
 return Json(value); 
} 
 
Please refer the sample link  
 
Please let us know if you need any further assistance. 
 
Regards, 
Balasubramanian Masilamani 



JJ Juan Jose Uribe February 12, 2018 02:55 PM UTC

Hi,

I tried your code sample but it didn´t work. When I click on save button on toolbar, it doesn´t do anything, it does not even reach the "NormalUpdate" method in controller. I copied your code in my project because if I open your´s I am getting some errors (because of the references paths).

I am attaching index.html and HomeController.cs
I am using visualstudio 2017

Attachment: Sample_a385425a.zip


JJ Juan Jose Uribe February 12, 2018 03:15 PM UTC

Hi,

I apologize I didnt understand your idea at first, but now I were able to use your sample to make my code run.´
It is running now. Thanks so much.




MS Mani Sankar Durai Syncfusion Team February 13, 2018 03:43 AM UTC

Hi Juan, 

We are happy to hear that your problem has been solved.  

Please let us know if you need further assistance.  

Regards, 
Manisankar Durai. 


Loader.
Up arrow icon