Reduce choice

Hello
I have a grid with somes foreign keys. 3 foreign keys are related.

public class A
{
int k1 (primary key)
}
public class B
{
int k2 (primary key)
int k1 (foreign key, primary key of class A)
}
public class C
{
int k3 (primary key)
int k1 (foreign key, primary key of class A)
}
A (1), A(2), A(3)
B(1,1), B(2,3), B(3,3)
C(1,2), C(2,2) C(3,1), C(4,3)
For example if I select A = 3 I when that B was reduced B(2,3), B(3,3) and C(4,3)
I have use MVC. Is it possible? Do you have some link?

Thank you
Best Regards

5 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team November 8, 2017 12:49 PM UTC

Hi Atolgan, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and we suspect that you have three Grids in a page. Every Grid have some amount records with in. If I am going to select third record in first grid then you need to show the second and third Grids record as you want.  

If the suspected details are not related to your query than please provide the following the details for better assistance. 

  1. Share pictorial representation of your requirement.
  2. Share your requirement on Grid with some more details.
  3. Share any screen shots or video demonstration of your requirement.

Regards, 
Thavasianand S. 



TH TheDarkBoz November 8, 2017 10:52 PM UTC

Hello 

My grid is 


@using BaranBackOffice_Application.App_GlobalResources

@using BaranBackOffice_Application.ViewModels

<h3>@ModeleResource.Nom</h3>

@(Html.EJ().Grid<ModeleViewModel>("ModeleGrid")

      .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.Modeles).InsertURL("InsertModele").UpdateURL("UpdateModele").Adaptor(AdaptorType.RemoteSaveAdaptor))

      .AllowSorting()

      .EditSettings(edit => { edit.AllowAdding().AllowEditing(); })

      .ToolbarSettings(toolbar =>

      {

          toolbar.ShowToolbar().ToolbarItems(items =>

          {

              items.AddTool(ToolBarItems.Add);

              items.AddTool(ToolBarItems.Edit);

              items.AddTool(ToolBarItems.Update);

              items.AddTool(ToolBarItems.Cancel);

          });

      })

      .IsResponsive()

      .Columns(col =>

      {

          col.Field(p => p.mod_Id).HeaderText(ModeleResource.mod_Id).IsIdentity(true).IsPrimaryKey(true).Visible(false).Add();

          col.Field(p => p.mod_Reference).HeaderText(ModeleResource.mod_Reference).ValidationRules(v => v.AddRule("required", true)).Add();

          col.Field(p => p.mod_Nom).HeaderText(ModeleResource.mod_Nom).ValidationRules(v => v.AddRule("required", true)).Add();

          col.Field(p => p.mod_TmoId).HeaderText(TypeModeleResource.tmo_Nom).ValidationRules(v => v.AddRule("required", true))

              .ForeignKeyField("tmo_Id").ForeignKeyValue("tmo_Nom").DataSource((IEnumerable<object>)ViewBag.TypeModeles).Add();

          col.Field(p => p.mod_CliId).HeaderText(ClientResource.cli_Nom).ValidationRules(v => v.AddRule("required", true))

              .ForeignKeyField("cli_Id").ForeignKeyValue("cli_Nom").DataSource((IEnumerable<object>)ViewBag.Clients).Add();

          col.Field(p => p.mod_GriId).HeaderText(GriffeResource.gri_Nom).ValidationRules(v => v.AddRule("required", true))

              .ForeignKeyField("gri_Id").ForeignKeyValue("gri_Nom").DataSource((IEnumerable<object>)ViewBag.Griffes).Add();

          col.Field(p => p.mod_CatId).HeaderText(CatalogueResource.cat_Nom).ValidationRules(v => v.AddRule("required", true))

              .ForeignKeyField("cat_Id").ForeignKeyValue("cat_Nom").DataSource((IEnumerable<object>)ViewBag.Catalogues).Add();

          col.Field(p => p.mod_Couleur).HeaderText(ModeleResource.mod_Couleur).Add();

          col.HeaderText("Détail").Commands(command =>

          {

              command.Type("detail")

                  .ButtonOptions(new Syncfusion.JavaScript.Models.ButtonProperties()

                  {

                      Text = "Détail",

                      Width = "100px",

                      Click = "Detail"

                  }).Add();

          }).Add();

          col.Field(p => p.mod_UserCreation).HeaderText(ModeleResource.mod_UserCreation).Visible(false).Add();

          col.Field(p => p.mod_UserModification).HeaderText(ModeleResource.mod_UserModification).Visible(false).Add();

          col.Field(p => p.mod_DateCreation).HeaderText(ModeleResource.mod_DateCreation).Visible(false).Add();

          col.Field(p => p.mod_DateModification).HeaderText(ModeleResource.mod_DateModification).Visible(false).Add();

      }))

The important part is


    col.Field(p => p.mod_CliId).HeaderText(ClientResource.cli_Nom).ValidationRules(v => v.AddRule("required", true))

              .ForeignKeyField("cli_Id").ForeignKeyValue("cli_Nom").DataSource((IEnumerable<object>)ViewBag.Clients).Add();

          col.Field(p => p.mod_GriId).HeaderText(GriffeResource.gri_Nom).ValidationRules(v => v.AddRule("required", true))

              .ForeignKeyField("gri_Id").ForeignKeyValue("gri_Nom").DataSource((IEnumerable<object>)ViewBag.Griffes).Add();

          col.Field(p => p.mod_CatId).HeaderText(CatalogueResource.cat_Nom).ValidationRules(v => v.AddRule("required", true))

              .ForeignKeyField("cat_Id").ForeignKeyValue("cat_Nom").DataSource((IEnumerable<object>)ViewBag.Catalogues).Add();

          col.Field(p => p.mod_Couleur).HeaderText(ModeleResource.mod_Couleur).Add();


Because the primary key cli_id is foreign key for the class Modele/Griffe and Catalogue

So when in the grid Modele if I select a Client, I want to filter Griffe and Catalogue with only the same foreign key

Please find the main files in attachment


Attachment: Grid_65b94715.zip


TS Thavasianand Sankaranarayanan Syncfusion Team November 9, 2017 12:27 PM UTC

Hi Atolgan, 

Thanks for your update. 

We have analyzed your query and we suspect that you want to filter the second Grid records based on we select the record in First Grid. So, we suggest you to use the rowSelected event of ejGrid control to update the dataSource of second Grid   

Refer the below code example. 


@(Html.EJ().Grid<object>("MasterGrid") 
 
    .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource1).UpdateURL("/Grid/Update").InsertURL("/Grid/Insert") 
.RemoveURL("/Grid/Remove").Adaptor(AdaptorType.RemoteSaveAdaptor)) 
    .AllowPaging() 
    .PageSettings(page => page.PageSize(5)) 
    .AllowSelection() 
    .SelectedRowIndex(0) 
    .ClientSideEvents(eve => { eve.RowSelected("rowSelected"); }) 
     
     ---- 
 
    .Columns(col => 
    { 
        col.Field("OrderID").HeaderText("OrderID").Width(100).Add(); 
 
        col.Field("EmployeeID").HeaderText("Employee Name").ForeignKeyField("EmployeeID").ForeignKeyValue("FirstName") 
.DataSource((IEnumerable<object>)ViewBag.dataSource2).TextAlign(TextAlign.Right) 
.Width(125).Add(); 
         
        ---- 
                
    }) 
) 
 
@(Html.EJ().Grid<object>("DetailGrid") 
     
     ---- 
 
    .Columns(col => 
    { 
        col.Field("EmployeeID").HeaderText("Employee ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(100).Add(); 
        col.Field("FirstName").HeaderText("First Name").Width(100).Add(); 
 
        -----         
 
 
   }) 
) 
 
 
<script type="text/javascript"> 
 
    function rowSelected(args) { // rowSelected event of first Grid 
 
        var employeeID = args.data.EmployeeID; 
 
        var detaildata = ej.DataManager(window.employeeView).executeLocal(ej.Query().where("EmployeeID", ej.FilterOperators.equal, employeeID, false)); 
 
        var gridObj = $("#DetailGrid").ejGrid("instance"); 
        gridObj.dataSource(ej.DataManager(detaildata)); // update the filtered dataSource to the second Grid 
    } 
</script> 



We have prepared a sample and it can be downloadable from the below location. 


Refer the help documentation. 





Regards, 
Thavasianand S. 



TH TheDarkBoz November 9, 2017 11:41 PM UTC

Hello

Thank you. Not exactly. It is the same grid but differents column.  I will try to adapt the code in my example


TS Thavasianand Sankaranarayanan Syncfusion Team November 10, 2017 04:41 AM UTC

Hi Atolgan, 

Thanks for your update. 

You can try to adapt your code example with the provided sample or else provide the following details for better assistance. 

  1. Share the exact requirement that you want to accomplish with Grid control.
  2. Share a screen shot or video demonstration of your requirement.
  3. If possible share your sample.

Regards, 
Thavasianand S. 


Loader.
Up arrow icon