Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grid DetailRow only if property exists #106

Closed
jvanderbiest opened this issue Nov 30, 2016 · 4 comments
Closed

Grid DetailRow only if property exists #106

jvanderbiest opened this issue Nov 30, 2016 · 4 comments

Comments

@jvanderbiest
Copy link

I would like to only show a detail template if a specific property (Category) exists. Currently it renders an expand icon if there is no detail template content. The problem is that I cannot use an *ngIf directive on the template element itself as I don't have access to the property.

Plunker: http://plnkr.co/edit/CKERCaoU4PEAi7Qya9VT?p=preview

Original stackoverflow question: http://stackoverflow.com/questions/40883426/grid-detailrow-only-if-property-exists/

@rusev
Copy link

rusev commented Dec 1, 2016

We can introduce condition to the kendoDetailTemplate directive where based on dataItem and rowIndex (master row index) you can build your conditional logic. Here is how detail template definition might look in the consumer component:

     <div *kendoDetailTemplate="let dataItem, let rowIndex = rowIndex; condition: myCondition">
        <category-details [category]="dataItem"></category-details>
    </div>

with <template> element:

    <template kendoDetailTemplate let-dataItem let-rowIndex="rowIndex"
      [kendoDetailTemplateCondition]="myCondition">
        <category-details [category]="dataItem"></category-details>
    </template>

and here is how myCondition function looks like:

  myCondition(dataItem: any, rowIndex: number) { return dataItem.CategoryID % 2 == 0; }

However there is an open question - what do you expect to see in the expand/collapse column when there isn't detail template for that master row?

Here is a how all this might look with expand/collapse icon removed if myCondition function returns false:
conditionaldetailtemplate

@jvanderbiest
Copy link
Author

jvanderbiest commented Dec 1, 2016

@rusev If there isn't a detail row, there should be no expand icon. Looks good in your screenshot and +1 for the condition approach!

@rusev
Copy link

rusev commented Dec 1, 2016

@jvanderbiest I'm logging this for implementation. We will update this issue once the Grid package is released with this functionality.

@rusev rusev closed this as completed Dec 1, 2016
@bhoopaljanga
Copy link

bhoopaljanga commented Jun 29, 2018

can we show/hide this based on input, the condition works with only the current dataItem we want to enable with a flag across the app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants