Need help on DataEvents property (JqGridColumnDataEvent/Cascaded DropDownList )

Oct 9, 2013 at 2:15 PM
Hi,

I am trying to implement Cascaded DropDownList in the edit form but without any success,
I have gone through below links for help.

https://tpeczek.codeplex.com/discussions/429392
https://tpeczek.codeplex.com/discussions/286543

If we have some quick sample code of implementing JqGridColumnDataEvent .. it will help us a lot.

I am trying to a achieve this : when ItemCategory dropdownlist is changed .. Items under selected ItemCategory need to be populated.

Thanks
NS
Coordinator
Oct 9, 2013 at 2:36 PM
Hi,

Implementing cascade DropDownList is a little bit challenging.

The threads you have linked are showing good examples on usage of JqGridColumnDataEvent but proper implementation of cascade drop down requires much more than that as it introduces dependencies between columns.

This is one of the issue I have on my plate for next release: Add support for cascade selects in searching and editing. I'm wotking on it and I don't have any demos yet.

Regards,
Tomasz Pęczek
Dec 2, 2013 at 9:19 AM
Hi,

Greetings,

Any progress on cascade dropdownlist. I seriously required this function to move ahead.

Thank you,
Coordinator
Dec 2, 2013 at 11:44 AM
Hi,

I will update this thread with information as soon as the prerelease package with that functionality will be available.

Regards,
Tomasz Pęczek
Coordinator
Dec 13, 2013 at 11:07 PM
Hi

I have released for testing an alpha package Lib.Web.Mvc 6.4.0-alpha6 at MyGet, (more details on how can you use a prerelease package can be found here), it introduces JqGridColumnEditTypes.SelectsCascadeParent which should provide the functionality described in the first post (you also need to provide ChildName).

Regards,
Tomasz Pęczek
Dec 22, 2013 at 11:29 AM
Hi,

Thank you for your update. I will check the same and keep you posted.


Thank you,
Dec 22, 2013 at 5:12 PM
Edited Dec 22, 2013 at 6:01 PM
Hi,
some thing is wrong. I am not able to work this out 
[ScaffoldColumn(false)]
[Required]
public long AssetCategoryID { get; set; }

[JqGridColumnSearchable(true, "GetCategoryName", "AssestMain", SearchType = JqGridColumnSearchTypes.Select, SearchOperators = JqGridSearchOperators.Eq | JqGridSearchOperators.Ne)]
__[JqGridColumnEditable(true, "GetCategoryName", "AssestMain", EditType = JqGridColumnEditTypes.SelectsCascadeParent, FormRowPosition = 2, FormColumnPosition = 2, ChildName = "ItemName")]
__[DisplayName("Item Category")]
[Required]
public string ItemCategoryName { get; set; }

[ScaffoldColumn(false)]
[Required]
public long ItemID { get; set; }

[JqGridColumnSearchable(true, "GetItemName", "AssestMain", SearchType = JqGridColumnSearchTypes.Select, SearchOperators = JqGridSearchOperators.Eq | JqGridSearchOperators.Ne)]
[JqGridColumnEditable(true, "GetItemName", "AssestMain", EditType = JqGridColumnEditTypes.Select, FormRowPosition = 2, FormColumnPosition = 3)]
[DisplayName("Item Name")]
[Required]
public string ItemName { get; set; }
Thxs
Dec 22, 2013 at 5:59 PM
Furthermore , on ItemCategoryName change it calls GetItemName function, but how can I capture AssetCategoryID. Is there any JqGridRequest for such scenario or I am doing totally wrong , Please advice
  public ActionResult GetItemName()
        {
            Dictionary<long, string> ItemNameList = new Dictionary<long, string>();
            foreach (tblItem ItemList in _ItemRepository.FindAll())
                ItemNameList.Add(ItemList.ItemID, ItemList.ItemName);
            return PartialView("Select", ItemNameList);
        }
Thank you,
Coordinator
Dec 22, 2013 at 7:25 PM
Hi,

If I'm reading your code correctly you want ItemName to be dependent on ItemCategoryName - this is how your cascade is configured. So when the user will change the Item Category drop down you will get a request to GetItemName() with an additional parameter parentVal which will represent the value of parent select:
public ActionResult GetItemName(string parentVal)
{
    Dictionary<long, string> ItemNameList = new Dictionary<long, string>();
    foreach (tblItem ItemList in _ItemRepository.FindAll())
        ItemNameList.Add(ItemList.ItemID, ItemList.ItemName);
    return PartialView("Select", ItemNameList);
}
Dec 23, 2013 at 10:30 AM
Hi,

My issue is resolved. Thank you for this feature.


Regards,
Coordinator
Dec 23, 2013 at 11:07 AM
Hi,

I'm happy to hear that - after all I do it for the users :).

Regards,
Tomasz Pęczek
Jan 22, 2014 at 2:07 PM
hi,

In Edit mode below code is not working. parentVal is null. Please help to workaround this issue.
public ActionResult GetItemName(string parentVal)
{
    Dictionary<long, string> ItemNameList = new Dictionary<long, string>();
    foreach (tblItem ItemList in _ItemRepository.FindAll())
        ItemNameList.Add(ItemList.ItemID, ItemList.ItemName);
    return PartialView("Select", ItemNameList);
}
Thanking you in advance.
Coordinator
Jan 22, 2014 at 3:58 PM
Edited Jan 22, 2014 at 4:00 PM
Hi,

Which edit mode are you trying to use? The JqGridColumnEditTypes.SelectsCascadeParent is valid only for inline editing, other editing and searching modes doesn't support it. This because of current architecture of the jqGrid itself, there is no way for getting the actual values while the edit/search fields are being build.

Regards,
Tomasz Pęczek