We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Sorting of a column that uses a custom template

Thread ID:

Created:

Updated:

Platform:

Replies:

116867 Jun 23,2014 11:39 AM Jun 26,2014 12:51 AM JavaScript 3
loading
Tags: ejGrid
Neil
Asked On June 23, 2014 11:39 AM

When using a custom template for a column such as this one

<script type="text/x-jsrender" id="colourTemplate">
    {{if Colour && Colour.Name}}
        <div class="colour-preview" style="background-color: {{:Colour.Hex }};"></div>
        {{:Colour.Name}}
    {{/if}}
</script>

How can the sorting of the column be updated so that they are ordered by the 'Name' property? 

does it require adding some comparer function to the Colour object? 

or defining a function to use similar to how you can define custom functions when doing an array sort?


Ragavee U S [Syncfusion]
Replied On June 24, 2014 09:05 AM

Hi Neil

 

We have analyzed your requirement for performing sorting operation in the customTemplate column. As per the behavior, we should not perform filtering, sorting, editing and grouping in Unbound columns. To perform such operations the column must be bound to the grid datasource.

 

Also the sorting operation is performed based on the field property of the column. So if you want to perform sorting to the customTemplate column based on the Name property, please refer the below code snippet.

 

<script type="text/x-jsrender" id="columnTemplate">

    {{if Color && Color.Name}}

        <div style="height:20px;background-color: {{:Color.Hex }};"></div>

        {{:Color.Name}}

    {{/if}}

</script>

 

<script>

$("#Grid").ejGrid({

columns: [                                            

         { field: "Color.Name", headerText: 'Template Column', textAlign: ej.textAlign.Left, width: 100,columnTemplate: true, templateId: "#columnTemplate"},

. . .]

. . .

</script>

 

For your convenience, we have created a simple sample for performing sorting operation on customTemplate column. The sample can be downloaded from the attachment.

 

Please let us know if you need any further assistance.

 

Regards

Ragavee U S



Attachment: Sample_75af1282.zip

Neil
Replied On June 25, 2014 10:27 AM

Thank you that worked.

Madhu Sudhanan P [Syncfusion]
Replied On June 26, 2014 12:51 AM

Hi Neil,

Thanks for your update. Please get back to us if you require further assistance. We will be happy to help you out.

Regards,
Madhu Sudhanan. P

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;