Grouping Drop Down List in Grid

Hi,

I'm trying to get a grouping drop down list working in a batch edit grid.  I am using "e-edit template" to accomplish this.  When adding new rows I can get the grouping drop down list to render properly but I have no idea what the "read" function should be.

Here is the code:
<code>
<ej-grid id="FlatGrid" allow-paging="true" enable-alt-row="true" action-failure="failure" allow-keyboard-navigation="true" allow-resizing="true" allow-resize-to-fit="true" create="createGrid">
    <e-datamanager url="/Telecom/UsersDataSource" batch-url="/Telecom/UsersBatchUpdate" adaptor="UrlAdaptor" />
    <e-edit-settings allow-editing="true" allow-adding="true" allow-deleting="true" edit-mode="@(EditMode.Batch)" show-confirm-dialog="true" show-delete-confirm-dialog="true" />
    <e-toolbar-settings show-toolbar="true" toolbar-items="@(new List<string>() {"add","update","cancel" })"></e-toolbar-settings>
    <e-columns>
        <e-column field="Id" is-primary-key="true" visible="false"></e-column>
        <e-column field="SecurityUserId" header-text="User" foreign-key-field="Id" foreign-key-value="FullName" datasource="@users">
            <e-edit-template create="create" read="read" write="write">
            </e-edit-template>
        </e-column>
    </e-columns>
</ej-grid>

<script type="text/javascript">

    function create() {
        return $("<input>");

    }

function read(args) {
       // this is obviously wrong
        var data = args.ejDropDownList("getSelectedValue");
        return args.ejDropDownList(data);
}

    function write(args) {
        //this appears to be working
        args.element.ejDropDownList({
            width: "100%",
            dataSource: args.column[1].dataSource,
            watermarkText: "Select a user",
            allowGrouping: true,
            fields: { text: "FullName", value: "Id", category: "ActiveGrouping" },
            value: args.rowdata !== undefined ? args.rowdata["SecurityUserId"] : ""
        });
       
    }
</script>

</code>

Thanks!
Chris

3 Replies

BM Balasubramanian Masilamani Syncfusion Team March 1, 2018 05:27 AM UTC

Hi Chris, 
Thanks for contacting Syncfusion support. 
We have checked your query and we found that the return of “args” in read function given in your code snippet is incorrect. Please refer the code snippet given below 
Code sample: 
………………….. 
function read(args) {
 
        return args.ejDropDownList("getSelectedValue");
}
 
…………… 

Please let us know if you need further assistance 

Regards, 
Balasubramanian Masilamani 



CH Chris March 1, 2018 06:18 PM UTC

Hi,

I figured it out.  It is a little different then what you suggested, but you started me on the right path.  Here is what I came up with:

    function read(args) {
        var selText = args.ejDropDownList("getValue");
        var selVal = args.ejDropDownList("getSelectedValue");
        return { text: selText, value: selVal };
    }

Thanks,
Chris


SE Sathyanarayanamoorthy Eswararao Syncfusion Team March 2, 2018 03:07 PM UTC

Hi Chris, 

We are glad to hear that your issue has been resolved. 
If you need any further assistance please get back to us. 

Regards, 
Sathyanarayanamoorthy 


Loader.
Up arrow icon