|
| 1 | +--- |
| 2 | +outline: [2, 4] |
| 3 | +--- |
| 4 | +# Size Limit |
| 5 | + |
| 6 | +Every UI5 JSON model has a built-in upper limit on the number of items it will expose to a list binding. By default this limit is `100`. If you bind a `ComboBox`, `Table` or any other aggregation to a table that contains more than 100 entries, only the first 100 are rendered — the rest are silently dropped. This is a UI5 design decision, documented under [`sap.ui.model.Model#setSizeLimit`](https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.model.Model%23methods/setSizeLimit). |
| 7 | + |
| 8 | +abap2UI5 exposes this setting through the built-in client event `SET_SIZE_LIMIT`, so you can raise (or reset) the limit per view directly from ABAP. |
| 9 | + |
| 10 | +### Set the Limit |
| 11 | +Trigger the event from your controller with `client->action`. The first argument is the new limit, the second is the view key (`MAIN`, `NEST`, `NEST2`, `POPUP`, `POPOVER`) — use the constants in `client->cs_view` to stay type-safe: |
| 12 | +```abap |
| 13 | +client->action( |
| 14 | + val = z2ui5_if_client=>cs_event-set_size_limit |
| 15 | + t_arg = VALUE #( |
| 16 | + ( `1000` ) |
| 17 | + ( client->cs_view-main ) ) ). |
| 18 | +``` |
| 19 | +After this call, the model bound to the main view accepts up to 1.000 entries per binding. The setting is remembered across roundtrips — once raised, it stays in effect until you reset it or leave the app. |
| 20 | + |
| 21 | +### Reset the Limit |
| 22 | +To restore the default of `100`, omit the limit argument and pass only the view key: |
| 23 | +```abap |
| 24 | +client->action( |
| 25 | + val = z2ui5_if_client=>cs_event-set_size_limit |
| 26 | + t_arg = VALUE #( ( client->cs_view-main ) ) ). |
| 27 | +``` |
| 28 | + |
| 29 | +### Complete Example |
| 30 | +The snippet below shows a `ComboBox` filled with 105 entries. Without raising the size limit, the dropdown would stop at item 100. A small form lets the user adjust the limit and the number of entries at runtime: |
| 31 | +```abap |
| 32 | +CLASS z2ui5_cl_sample_size_limit DEFINITION PUBLIC. |
| 33 | +
|
| 34 | + PUBLIC SECTION. |
| 35 | + INTERFACES z2ui5_if_app. |
| 36 | +
|
| 37 | + TYPES: |
| 38 | + BEGIN OF ty_s_combo, |
| 39 | + key TYPE string, |
| 40 | + text TYPE string, |
| 41 | + END OF ty_s_combo. |
| 42 | + DATA t_combo TYPE STANDARD TABLE OF ty_s_combo WITH EMPTY KEY. |
| 43 | + DATA mv_size_limit TYPE i VALUE 100. |
| 44 | + DATA mv_combo_number TYPE i VALUE 105. |
| 45 | +
|
| 46 | + PROTECTED SECTION. |
| 47 | + PRIVATE SECTION. |
| 48 | +ENDCLASS. |
| 49 | +
|
| 50 | +CLASS z2ui5_cl_sample_size_limit IMPLEMENTATION. |
| 51 | + METHOD z2ui5_if_app~main. |
| 52 | +
|
| 53 | + CASE client->get( )-event. |
| 54 | + WHEN `UPDATE_LIMIT`. |
| 55 | + client->action( |
| 56 | + val = z2ui5_if_client=>cs_event-set_size_limit |
| 57 | + t_arg = VALUE #( ( CONV #( mv_size_limit ) ) ( client->cs_view-main ) ) ). |
| 58 | + client->message_toast_display( `Size limit updated` ). |
| 59 | + RETURN. |
| 60 | +
|
| 61 | + WHEN `UPDATE_MODEL`. |
| 62 | + t_combo = VALUE #( ). |
| 63 | + DO mv_combo_number TIMES. |
| 64 | + INSERT VALUE #( key = sy-index text = sy-index ) INTO TABLE t_combo. |
| 65 | + ENDDO. |
| 66 | + client->view_model_update( ). |
| 67 | + RETURN. |
| 68 | + ENDCASE. |
| 69 | +
|
| 70 | + DO mv_combo_number TIMES. |
| 71 | + INSERT VALUE #( key = sy-index text = sy-index ) INTO TABLE t_combo. |
| 72 | + ENDDO. |
| 73 | +
|
| 74 | + DATA(view) = z2ui5_cl_xml_view=>factory( ). |
| 75 | + view->page( `Size Limit Demo` |
| 76 | + )->simple_form( title = `Settings` editable = abap_true |
| 77 | + )->content( `form` |
| 78 | + )->label( `setSizeLimit` |
| 79 | + )->input( value = client->_bind_edit( mv_size_limit ) |
| 80 | + )->button( |
| 81 | + text = `update size limit` |
| 82 | + press = client->_event( `UPDATE_LIMIT` ) |
| 83 | + )->label( `Number of Entries` |
| 84 | + )->input( value = client->_bind_edit( mv_combo_number ) |
| 85 | + )->button( |
| 86 | + text = `update number of entries` |
| 87 | + press = client->_event( `UPDATE_MODEL` ) |
| 88 | + )->label( `ComboBox` |
| 89 | + )->combobox( items = client->_bind( t_combo ) |
| 90 | + )->item( key = `{KEY}` text = `{TEXT}` ). |
| 91 | + client->view_display( view->stringify( ) ). |
| 92 | +
|
| 93 | + ENDMETHOD. |
| 94 | +ENDCLASS. |
| 95 | +``` |
| 96 | + |
| 97 | +### Other Views |
| 98 | +The same call applies to nested views, popups and popovers — just swap the view key: |
| 99 | +```abap |
| 100 | +" Popup |
| 101 | +client->action( |
| 102 | + val = z2ui5_if_client=>cs_event-set_size_limit |
| 103 | + t_arg = VALUE #( ( `500` ) ( client->cs_view-popup ) ) ). |
| 104 | +
|
| 105 | +" Popover |
| 106 | +client->action( |
| 107 | + val = z2ui5_if_client=>cs_event-set_size_limit |
| 108 | + t_arg = VALUE #( ( `500` ) ( client->cs_view-popover ) ) ). |
| 109 | +
|
| 110 | +" Nested view |
| 111 | +client->action( |
| 112 | + val = z2ui5_if_client=>cs_event-set_size_limit |
| 113 | + t_arg = VALUE #( ( `500` ) ( client->cs_view-nested ) ) ). |
| 114 | +``` |
| 115 | + |
| 116 | +::: tip **When to raise it** |
| 117 | +Raise the limit only as high as you actually need. Large bindings increase memory consumption on the frontend and slow down rendering. For very large datasets, prefer a server-side pattern (OData with `growing`, paging, filtering) instead of pushing everything into the model. |
| 118 | +::: |
| 119 | + |
| 120 | +For a runnable sample, see `Z2UI5_CL_DEMO_APP_071` in the [samples repository](https://github.com/abap2UI5/samples). |
0 commit comments