# Showing string when data is null

**URL:** <https://forums.knack.com/t/showing-string-when-data-is-null/10309>\
**Category:** API & Custom Code\
**Created:** [March 12, 2015, 2:23am UTC](https://forums.knack.com/t/showing-string-when-data-is-null/10309 "2015-03-12T02:23:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElijahAngo40597](https://avatars.discourse-cdn.com/v4/letter/e/77aa72/32.png) [@ElijahAngo40597](https://forums.knack.com/u/ElijahAngo40597)\
**Post date:** [March 12, 2015, 2:23am UTC](https://forums.knack.com/t/showing-string-when-data-is-null/10309/1 "2015-03-12T02:23:24Z")

</div>

&nbsp;suppose YY table has no data now.so in the interface its showing nothing. but here i want to show "there is no data right now" string.how can i do this?

---

<div class="post-metadata">

**Author:** ![MarcusCowl17941](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@MarcusCowl17941](https://forums.knack.com/u/MarcusCowl17941)\
**Post date:** [June 29, 2016, 10:24am UTC](https://forums.knack.com/t/showing-string-when-data-is-null/10309/2 "2016-06-29T10:24:50Z")

</div>

Thought I'd add working code including the change from Nicolas. You can add it as many times as you like and point each to specific views :

$(document).on('knack-view-render.view\_490', function (event, view, data) {

&nbsp; &nbsp; &nbsp;

&nbsp; &nbsp; // Target the 'No Data' string and replace with your own text

&nbsp;

&nbsp; &nbsp; $('# **view\_490** td.kn-td-nodata').text('_No Active Invoices_');

&nbsp;

})

$(document).on('knack-view-render.view\_515', function (event, view, data) {

&nbsp; &nbsp; &nbsp;

&nbsp; &nbsp; // Target the 'No Data' string and replace with your own text

&nbsp;

&nbsp; &nbsp; $('# **view\_515** td.kn-td-nodata').text('_No Active Quotes_');

&nbsp;

})

$(document).on('knack-view-render.view\_160', function (event, view, data) {

&nbsp; &nbsp; &nbsp;

&nbsp; &nbsp; // Target the 'No Data' string and replace with your own text

&nbsp;

&nbsp; &nbsp; $('# **view\_160** td.kn-td-nodata').text('_No Notes_');

&nbsp;

})

Hope this helps someone. :)

---

<div class="post-metadata">

**Author:** ![Nic](https://avatars.discourse-cdn.com/v4/letter/n/45deac/32.png) [@Nic](https://forums.knack.com/u/Nic)\
**Post date:** [May 28, 2015, 7:51pm UTC](https://forums.knack.com/t/showing-string-when-data-is-null/10309/3 "2015-05-28T19:51:40Z")

</div>

Hey John,

You'll want to target the specific table in the selector:

$('#view\_1&nbsp;td.kn-td-nodata').text('No Data Available');

---

<div class="post-metadata">

**Author:** ![JohnKatez44398](https://avatars.discourse-cdn.com/v4/letter/j/977dab/32.png) [@JohnKatez44398](https://forums.knack.com/u/JohnKatez44398)\
**Post date:** [May 26, 2015, 4:34pm UTC](https://forums.knack.com/t/showing-string-when-data-is-null/10309/4 "2015-05-26T16:34:04Z")

</div>

Hey Nic,

I'm using your code and it works great, but it changes the text for every table on a page. Is there a way to target a specific table? I even tried updating the view\_ID to no avail, it still updates the text for every table on a page.

---

<div class="post-metadata">

**Author:** ![ElijahAngo40597](https://avatars.discourse-cdn.com/v4/letter/e/77aa72/32.png) [@ElijahAngo40597](https://forums.knack.com/u/ElijahAngo40597)\
**Post date:** [March 15, 2015, 1:40am UTC](https://forums.knack.com/t/showing-string-when-data-is-null/10309/5 "2015-03-15T01:40:34Z")

</div>

Thanks for your help man. please check my code block:  
  
$(document).on(‘knack-view-render.view\_1’, function (event, view, data) {  
 var obj = JSON.stringify(data);  
 if(obj=="")  
&nbsp;print some thing

&nbsp;})

whenver null is returned i always gettting . so that i bound to code like this.is there any other option?

---

<div class="post-metadata">

**Author:** ![Nic](https://avatars.discourse-cdn.com/v4/letter/n/45deac/32.png) [@Nic](https://forums.knack.com/u/Nic)\
**Post date:** [March 13, 2015, 3:42pm UTC](https://forums.knack.com/t/showing-string-when-data-is-null/10309/6 "2015-03-13T15:42:35Z")

</div>

I made some modifications to the snippet for you. This will target a specific view you specify. Change view\_1 to the specific view ID for your page where you're trying to change this.

You can learn more about this here:

[http://helpdesk.knackhq.com/solution/categories/5000053588/folders/5000106828/articles/5000447139-customization-with-jquery-and-javascript](http://helpdesk.knackhq.com/solution/categories/5000053588/folders/5000106828/articles/5000447139-customization-with-jquery-and-javascript)

---

<div class="post-metadata">

**Author:** ![ElijahAngo40597](https://avatars.discourse-cdn.com/v4/letter/e/77aa72/32.png) [@ElijahAngo40597](https://forums.knack.com/u/ElijahAngo40597)\
**Post date:** [March 13, 2015, 3:24pm UTC](https://forums.knack.com/t/showing-string-when-data-is-null/10309/7 "2015-03-13T15:24:01Z")

</div>

or can u plz explain the code ? or any document link is thr?

&nbsp;

---

<div class="post-metadata">

**Author:** ![ElijahAngo40597](https://avatars.discourse-cdn.com/v4/letter/e/77aa72/32.png) [@ElijahAngo40597](https://forums.knack.com/u/ElijahAngo40597)\
**Post date:** [March 13, 2015, 12:47am UTC](https://forums.knack.com/t/showing-string-when-data-is-null/10309/8 "2015-03-13T00:47:16Z")

</div>

&nbsp;yes. i am talking about this one, but its generic . i want to change it for one table.

---

<div class="post-metadata">

**Author:** ![Nic](https://avatars.discourse-cdn.com/v4/letter/n/45deac/32.png) [@Nic](https://forums.knack.com/u/Nic)\
**Post date:** [March 12, 2015, 5:26pm UTC](https://forums.knack.com/t/showing-string-when-data-is-null/10309/9 "2015-03-12T17:26:23Z")

</div>

Hi Eli,

Are you talking about modifying the "No Data" string that is already there? Using some jQuery, you could replace that string for all your views:

&nbsp;&nbsp;

```
// You need to change view_1 to match the view you want to change this for.

$(document).on(‘knack-view-render.view\_1’, function (event, view, data) {

```
// Target the 'No Data' string and replace with your own text

$('td.kn-td-nodata').text('No Data Available');

```

})
```

&nbsp;&nbsp;
