question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Select Field : is it possible to reload via ajax on editTemplate?

See original GitHub issue

Is it possible to reload select field items on it field self when editTemplate is called? I try to do like this but not running sorry my English is not good

 {title:"Category",type:"select", name:"prodCatId", items:dataCategory,valueField:"prodCatId",textField:"prodCatDesc",
  editTemplate : function(){
   var sbuField = this._grid.fields[0];
   var $editControl = jsGrid.fields.select.prototype.editTemplate.call(this,arguments);
    
    $editControl.on("change", function(){
     var selectedSbuId = sbuField.editControl[0].value;
     var selectedprodCatId = $(this).val();
     $.ajax({
      type: "POST",
       url: "./getDataCategoryList",
       data:{"sbuId":selectedSbuId,"prodCatId":selectedprodCatId},
       success: function(data){
        dataCategory =  data
       },
       error : function(error){alert('error')}
      }); 
    });
    return $editControl;
 },
}

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
carlozSantiagocommented, Jul 21, 2017

@heiovsky , yes Right exactly like that

  1. select country canada
  2. select state A2
  3. add

so we have 1 record, and add new record

  1. select country United States
  2. select state A1
  3. add

now we have 2 different record, then click on Canada record, state field is empty. . how do i showed the data and choice ??

in my case, country and state items in deferent source. and state items have dynamic value depend on selected country. Sorry my English is not good…

1reaction
carlozSantiagocommented, Jul 21, 2017

I have 3 dependency dropdown, categoryA, categoryB, categoryC. the items of categoryC(items:dataCategory) depends on what i chose in the categoryA and categoryB, i use ajax to hit server and get list, it works and items for categoryC is change,

The problem when i chose dropdown on the other row into editing mode where the value(valueField:“prodCatId”) of the dropdown was not found in list(dataCategory) which i got before, so the dropdown showing empty,

ex: image

image

i try to reload just items (items:dataCategory) on $editControl, i use ajax again to hit server . In the hope of items(items:dataCategory) will be load again based on value of categoryA and categoryB in that row…

{title:"Category",type:"select", name:"prodCatId", items:dataCategory,valueField:"prodCatId",textField:"prodCatDesc",
  editTemplate : function(){
   var sbuField = this._grid.fields[0];
   var $editControl = jsGrid.fields.select.prototype.editTemplate.call(this,arguments);
    
    $editControl.on("change", function(){
     var selectedSbuId = sbuField.editControl[0].value;
     var selectedprodCatId = $(this).val();
     $.ajax({
      type: "POST",
       url: "./getDataCategoryList",
       data:{"sbuId":selectedSbuId,"prodCatId":selectedprodCatId},
       success: function(data){
        dataCategory =  data
       },
       error : function(error){alert('error')}
      }); 
    });
    return $editControl;
 },
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

reload data from select tag each ajax request - Stack Overflow
Your code is working fine but you need to empty option and append the new value you got it form ajax call. $('#subcarousel_type').empty();....
Read more >
joomla 3.x - Reload admin form after save field in database
In a custom component I need the user in the edit view of an item to be able to load a field in...
Read more >
Documentation - jsGrid
editTemplate is a function to create cell content of editing row. ... select. Select field renders <select> control in filter, inserting and editing...
Read more >
Reload or Refresh a Page after Ajax Success using jQuery
You can use the .reload() method inside an Ajax success callback function using jquery. ... Get file size, name and type from multiple...
Read more >
Refresh/Auto update dropdownlist - MSDN - Microsoft
I know something like this can be done using AJAX but I cannot seem to direct myself into right direction. Can some please...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found