livecode.com
  • Home
  • Download
  • Developers
  • Academy
  • Community
  • Store
  • Support
  • About
LiveCode Lessons » LiveCode Data Grid » How Do I Create Rows That Can Expand/Contract?

Topics

  • Introduction 5
    • What is the Data Grid?
    • Can You Show Me Some Examples?
    • How Do I Create My First Data Grid Table?
    • How Do I Create My First Data Grid Form?
    • Example: Creating a List of People
  • Data Grid Fundamentals 6
    • What Is This "Data Grid Templates" Stack That Appeared in My Project?
    • What is a Row Template?
    • What is a Column Template?
    • How Do I Populate a Data Grid With Data?
    • How Do I Customize A Form's Row Template?
    • How Do I Customize A Table's Columns?
  • Working With Data Grids (Forms & Tables) 14
    • How Do I Determine The Selected Line?
    • How Do I Get Data Associated With a Row or Column?
    • How Do I Add A Row Of Data To An Existing Data Grid?
    • How Do I Update Data In a Row?
    • How Do I Clear Data From a Data Grid?
    • How Do I Add a mouseDown Event To The Data Grid Without Breaking It?
    • How Can I Store An Option Menu Value When The User Makes a Selection?
    • How Do I Refresh a Data Grid After Making Changes to a Template Through Script?
    • How Do I Use A Template In Multiple Data Grids?
    • How Can I See What The Data Grid's Internal Array Currently Looks Like?
    • How Do I Get Aggregate Values for Columns?
    • How Do I Determine If the Data Grid Has Focus?
    • How Do I Export Data From A Data Grid?
    • How Do I Work with Checkboxes in a Data Grid?
  • Working With Data Grid Tables 13
    • How Do I Change Column Alignment?
    • How Do I Sort By A Column?
    • How Do I Resize Columns?
    • How Do I Override the Default Behavior For Rendering Data to a Cell?
    • How Do I Determine If a User Clicks In The Table Header?
    • How Do I Display a Contextual Menu When the User Clicks on a Column Header?
    • What If I Need to Work With htmlText, rtfText or unicodeText?
    • How Do I Display Line Numbers in a Table?
    • How Do I Customize Column Sorting?
    • How Do I Disable Column Sorting?
    • How Do I Perform An Action After the User Sorts a Data Grid?
    • How Do I Align Decimals in a Column?
    • How Can I Colorize Individual Lines in a Table?
  • Working With Data Grid Forms 4
    • How Do I Create a Form with Variable Line Heights?
    • How Do I Sort Records By A Specific Key's Values?
    • How Do I Create Rows That Can Expand/Contract?
    • How Can I Speed Up Drawing When "fixed row height" is False?
  • Using The Built-In Field Editor 6
    • How Do I Open a Table Cell For Editing?
    • How Can The User Edit Field Content in a Data Grid Form?
    • How Can I Edit The Text as UTF-8, UTF-16 or HTML?
    • How Can I Select The Text in the Edit Field When It Opens?
    • How Do I Save Changes The User Makes In An Editor Field To An External Data Source?
    • How Can I Customize The Field Editor Behavior?
  • Building Standalones With The Data Grid 1
    • What Do I Need to Do To Deploy a Standalone With A Data Grid?
  • Useful Things To Know 1
    • What Sorts of Things Should I Not Do In Order To Avoid Needless Suffering?
  • Advanced Options 3
    • Displaying Large Amounts of Data
    • Creating A Data Grid By Hand
    • How do I create a Datagrid dynamically from tab delimited data
  • API and Properties 3
    • Data Grid Properties
    • Data Grid API
    • Template Custom Properties & Messages

Last Updated

Feb 04, 2011

Download Manual PDF

Other Resources

  • Getting Started with LiveCode

  • Get Up and Running with LiveCode
  • Getting Started with LiveCode Development
  • LiveCode Concepts

  • Features, concepts and aspects of LiveCode
  • LiveCode Lessons

  • How To - Step-By-Step Guides To Tasks In LiveCode
  • How To - LiveCode Server Tasks
  • How To - LiveCode Mobile Tasks
  • How To - LiveCode Sample Scripts
  • How to - LiveCode Marketplace Products
  • How to Purchase and License LiveCode
  • Tutorials

  • Creating a Video Library Application
  • Data Grid

  • LiveCode Data Grid
  • Data Grid Tips & Tricks
  • Converting the Stock Program

Comments

0 for this lesson

  • Prev: How Do I Sort Records By A Specific Key's Values?
  • Next: How Can I Speed Up Drawing When "fixed row height" is False?

How Do I Create Rows That Can Expand/Contract?

This lesson will show you how to make a Data Grid form with rows that expand and contract when clicking on an arrow.

Attached Files

  • ExpandingRow.rev

Expanding and Contracting Rows

This is what the example stack looks like. By default all of the rows are contracted and only show names.

Clicking on the arrow next to a name expands the row to show the description of the person.

Setting the Data Grid Properties

To create a Data Grid form with rows that expand/contact you need to turn off "fixed control height" in the property inspector.

Note: To turn off the property using script you set the dgProp["fixed row height"] property to false.

Updating the Row Behavior Script

In order to get expanding rows working you need to take a couple of things into account in the Row Behavior Script.

In the FillInData message you should show or hide controls as necessary. The example stack stores the expanded state of each row in the "expanded" key.

In the LayoutControl message you need to readjust the position of the controls and background graphic based on whether or not the row is expanded or contracted. Since the "fixed row height" property is set to false the Data Grid computes the total height of the data based on the height of each row after calling LayoutControl.

When the user clicks on the arrow the example stack updates the expanded key in the row's data and then redraws the row. Using SetDataOfIndex in conjunction with RefreshIndex is the most efficient way to do this.

  • Prev: How Do I Sort Records By A Specific Key's Values?
  • Next: How Can I Speed Up Drawing When "fixed row height" is False?

Comments (0)

Add your comment

E-Mail me when someone replies to this comment
Brought to you by RunRev Ltd, Registered in Scotland, No. SC200728